
August 16th, 2004, 11:54 AM
|
 |
Contributing User
|
|
Join Date: May 2004
Location: Battle Creek, Michigan
Posts: 352
Time spent in forums: 30 sec
Reputation Power: 5
|
|
You can make use of the onKeyPress for text boxes & text areas, onChange for select option boxes, onClick for check boxes and radio buttons. It's not exactly perfect, but it does the job. Below is an example illustrating all three:
Javascript function:
Quote:
<script language="JavaScript">
function moveIT()
//This function moves the focus to the next field upon completing field.
{
if ( document.formname.textboxname.value.length == 3 )
{
document.formname.textboxname.focus();
}
if ( document.formname.textboxname.value.length == 7 )
{
document.formname.selectboxname.focus();
}
if (document.formname.selectboxname.options[0].selected == false)
{
document.formname.textareaname.focus();
}
if ( document.formname.textareaname.value.length == 50 )
{
document.formname.checkboxname.focus();
}
if (document.formname.checkboxname1.checked || document.formname.checkboxname2.checked)
{
document.formname.submit.focus();
}
}
| HTML form elements:
Quote:
Textboxes/Textareas: <input type="text" name="textboxname" size="3" tabindex="1" maxlength="3" onKeyPress="moveIT()">
Selectboxes: <select id="selectboxname" name="selectboxname" onChange="moveIT()">
Checkboxes: <INPUT type="checkbox" name="yes" onClick="moveIT()">
|
|