PDA

View Full Version : Focus Won't Work


Cleavis
08-13-2002, 02:24 PM
The Following Code Returns An Error:'document.order.onum' is null or not an object


The Counter Seems To Be Working Except For The Focus & Select Statements.

Any Help Would Be Appreciated.

Thanks

<SCRIPT LANGUAGE="JavaScript">
function onumValidate(){
var onum = new Array(8);
onum[0] = document.order.onum0.value;
onum[1] = document.order.onum1.value;
onum[2] = document.order.onum2.value;
onum[3] = document.order.onum3.value;
onum[4] = document.order.onum4.value;
onum[5] = document.order.onum5.value;
onum[6] = document.order.onum6.value;
onum[7] = document.order.onum7.value;

var invalid = " "; // Invalid character is a space
for (i = 0; i < 8; i++)
if (onum[i].indexOf(invalid) > -1) {
alert("Order Number " +[i] + " May Not Contain Spaces" )
document.order.onum[i].focus()
document.order.onum[i].select()
} else {
}
}
</script>

mordred
08-13-2002, 02:33 PM
document.order.elements["onum" + i].focus();
document.order.elements["onum" + i].select();

I think you miss a break statement too in your code.

Cleavis
08-13-2002, 02:36 PM
Thank You Very Much.