Hey all,
I have this JS that is tied to a drop down list box using this :
[CODE]
onActivate=”soFar=”;” onKeyDown=”limitTo(this, this.form.arc);”
…
what I am trying to do is make it to when the user hits the enter button (ascii 13?), the form will then postback
here is the js, any ideas?
[CODE]<script>
var soFar = “”;
function limitTo(sel, nextField)
{
var kc = window.event.keyCode;
// up down arrow keys
if ( kc == 40 || kc == 38 )
{
soFar = “”;
return;
}
// keyCode handler
window.event.cancelBubble = true;
window.event.returnValue = false;
//below is carriage return, line feed, tab
if ( kc == 10 || kc == 13 || kc == 9 )
{
nextField.focus();
return;
}
if ( kc == 8 )
{
if ( soFar.length > 0 ) soFar = soFar.substring( 0, soFar.length-1 );
} //below is the ascii for alpha/numeric + spacebar
else if ( kc < 32 || kc > 122 )
{
soFar = “”;
sel.selectedIndex = 0;
return;
}
else
{
soFar += String.fromCharCode(kc);
}
// now search for first match
var first = -1;
for ( var ix = 1; ix < sel.options.length; ++ix )
{
if ( soFar == sel.options[ix].text.toUpperCase().substring(0,soFar.length) )
{
first = ix;
break;
}
}
if ( first < 0 )
{
soFar = “”;
sel.selectedIndex = 0;
return;
}
sel.selectedIndex = first;
}
</script>