Click to See Complete Forum and Search --> : dynamically accessing form elements in loops


SnowBaby
10-16-2003, 06:16 AM
Ok I have a dynamically created form and need to do a verification check on it. I could write out a switch statment to do this however I'm starting to have long downloads simply because of the number of statements. I work mainly in .asp so I'm wondering if I can dynamically effect the form element I'm checking within the following loop. Each form element is named Student# with the # being a number from 1 to gsize.

in the example below I've put a # in where I'd need to effet the verification.

for (i = 1; i < gsize; i++){
if ( document.frmGroupSelect.Student#.value == "NotSelected" )
{alert ("Group member "+i+"has not been selected. Please complete the group"); return false;}}

Any help is apriciated. Thanx

Jon.

gil davis
10-16-2003, 07:04 AM
if (document.frmGroupSelect["Student" + i].value == "NotSelected")

SnowBaby
10-16-2003, 07:10 AM
:D

Thank you it works like a dream.

I've been trying to find out how that works for a ages.

JJ