This script places the cursor in the first field of a form when the page loads and when the form is reset or cleared. The script works with input types: text, textarea, radio, checkbox, password and Select drop-down boxes.
Add the below code to the <body> section of your page:
<scriptlanguage="javascript"type="text/javascript"> /* Visit http://www.yaldex.com/
for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin function
toForm(){ document.form.field1.selectedIndex=0; document.form.field2.value=""; document.form.field3.value=""; // Replace field1 in the script
with the field name of which you want to place the focus. } window.onload=toForm; // End --> </script> <FORMNAME="form"METHOD="POST"ACTION="#">
<SELECTNAME="field1"SIZE="1">
<OPTIONVALUE="one">Field
1 <OPTIONVALUE="two">also
field1 </SELECT> <BR> <INPUTTYPE="TEXT"NAME="field2"SIZE="10">
Field 2<BR> <INPUTTYPE="TEXT"NAME="field3"SIZE="10">
Field 3<BR>
<BR> <INPUTTYPE="SUBMIT"NAME="submit"VALUE="Submit">
<INPUT
TYPE="button"value="RESET"onclick="toForm();">
</FORM>