General
Use this script to create a form that will open on top of the existing page, using a hidden DIV. A default link is included to allow for JavaScript being turned off or unavailable.
Source Code
Paste this source code into the designated areas.
External file
Paste this code into an external JavaScript file named: popOverForm.js
Select code
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Roderick W. Divilbiss | http://www.rodsdot.com/Licensed under: Creative Commons License
*/
function showForm() {
oDiv = document.getElementById('theFormDiv');
oDiv.style.display='block';
return false;
}
function hideForm() {
oDiv = document.getElementById('theFormDiv');
oDiv.style.display='none';
return false;
}
CSS
Paste this code into your external CSS file or in the <style> section within the HEAD section of your HTML document.
Select code
#theFormDiv {
display:none;
position:absolute;
top:4em;
left:4em;
background-color:#EEE;
border:1px solid #000;
padding:1em;
margin:3em;
width:20em;
}
.nocss {
display:none;
}
Head
Paste this code into the HEAD section of your HTML document.
Select code
<script type="text/javascript" src="popOverForm.js"></script>
Body
Paste this code into the BODY section of your HTML document
Select code
<div id="theExample">
<p><a title="open form" href="contact.php" onclick="return showForm();">Click To Open Form</a></p>
</div>
<div id="theFormDiv">
<form method="post" id="frm">
<fieldset>
<legend>Contact Information</legend>
<table>
<tr>
<td><label id="label-first">First Name</td><td><input name="first" type="text"></td>
</tr><tr>
<td><label id="label-last">Last Name</td><td><input name="last" type="text"></td>
</tr><tr>
<td><label id="label-email">E-Mail</td><td><input name="email" type="text"></td>
</tr><tr>
<td><label id="label-city">Comments</td><td><textarea name="comment" type="text"></textarea></td>
</tr><tr>
<td><input type="submit" id="bSubmit" name="bSubmit" value="Submit" onclick="hideForm();"></td><td>
<input type="button" id="bCancel" name="bCancel" value="Cancel" onclick="hideForm();"></td>
</tr>
</table>
</fieldset>
</form>
</div>
We'll send this script to you!
Do you write JavaScripts? If you do, why not submit them to us ? We'll give you credit and a link back to your Web site.