Hello,
I'm hoping someone can help me with an easy solution. Here's what I'm trying to accomplish:
I have 5 form fields. Using javascript, each value is assigned to an array. I would like to use a loop to join each value (separated by a comma) and be assigned to a string variable (wholestring). The catch is that if any form field value is blank, it will be skipped. Here's what I've come up with so far, however, it's not working out for me:
var names = new Array();
var arraysize = names.length;
names[0] = frmOpt1.opt1N1.value;
names[1] = frmOpt1.opt1N2.value;
names[2] = frmOpt1.opt1N3.value;
names[3] = frmOpt1.opt1N4.value;
names[4] = frmOpt1.opt1N5.value;
var tellme = "";
for (var counter = 0; counter < arraysize; counter++){
if (names[counter] == "0"){
break;
}
else {
tellme = tellme + names[counter] + ", ";
}
}
var wholestring = tellme;
[/color red]
Any help would be greatly appreciated!
Thanks,
Dipesh.
I'm hoping someone can help me with an easy solution. Here's what I'm trying to accomplish:
I have 5 form fields. Using javascript, each value is assigned to an array. I would like to use a loop to join each value (separated by a comma) and be assigned to a string variable (wholestring). The catch is that if any form field value is blank, it will be skipped. Here's what I've come up with so far, however, it's not working out for me:
var names = new Array();
var arraysize = names.length;
names[0] = frmOpt1.opt1N1.value;
names[1] = frmOpt1.opt1N2.value;
names[2] = frmOpt1.opt1N3.value;
names[3] = frmOpt1.opt1N4.value;
names[4] = frmOpt1.opt1N5.value;
var tellme = "";
for (var counter = 0; counter < arraysize; counter++){
if (names[counter] == "0"){
break;
}
else {
tellme = tellme + names[counter] + ", ";
}
}
var wholestring = tellme;
[/color red]
Any help would be greatly appreciated!
Thanks,
Dipesh.