Hello,
I have the following javascript code that I want to shorten using a loop that will assign form field values to array elements:
var N = new Array();
N[0] = frmOpt1.opt1N0.value;
N[1] = frmOpt1.opt1N1.value;
N[2] = frmOpt1.opt1N2.value;
N[3] = frmOpt1.opt1N3.value;
N[4] = frmOpt1.opt1N4.value;[/color blue]
Here's what I've come up with, however, it's not working out for me:
var N = new Array();
for (var x = 0; x < 5; x++){
N[x] = frmOpt1.["opt1N" + x].value;
}[/color red]
Any help would be greatly appreciated - I'm a newbie
Thanks in advance
I have the following javascript code that I want to shorten using a loop that will assign form field values to array elements:
var N = new Array();
N[0] = frmOpt1.opt1N0.value;
N[1] = frmOpt1.opt1N1.value;
N[2] = frmOpt1.opt1N2.value;
N[3] = frmOpt1.opt1N3.value;
N[4] = frmOpt1.opt1N4.value;[/color blue]
Here's what I've come up with, however, it's not working out for me:
var N = new Array();
for (var x = 0; x < 5; x++){
N[x] = frmOpt1.["opt1N" + x].value;
}[/color red]
Any help would be greatly appreciated - I'm a newbie
Thanks in advance