[thelist] testing for empty in javascript or vbscript

Marc Seyon seyon at delime.com
Mon Jul 15 17:48:06 CDT 2002


Message from Tom Dell'Aringa (7/15/2002 03:29 PM)
>Do you have a code snippet? Anyway, you could do something like this.
>Have all your boxes named something like box1, box2 etc. Then
>
>for(i=0; i<=16; i++)
>{
>    box = "box" + i;
>    if(document.getElementById(box).value = "")
>       {

You don't have to have them all named similarly. Nor even have all as
checkboxes.

You can refer to any form element thusly
document.formname.elements[i]

And if you wish, even check whether the form element is a checkbox
document.formname.elements[i].type == 'checkbox'

With that, as Tom says, it's easy to iterate through with the for loop.

Hope this helps.
-marc



More information about the thelist mailing list