[thelist] testing for empty in javascript or vbscript

Chris W. Parker cparker at swatgear.com
Mon Jul 15 19:04:05 CDT 2002


> -----Original Message-----
> From: Jeremy Weiss [mailto:jweiss at cei.net]
> Sent: Monday, July 15, 2002 4:51 PM
>
>       zip = "zip" + i;

on this line you are making the variable called 'zip' hold the string
"zip" + i. which, depending what value 'i' has, would be something like
"zip1" or "zip2". which is not what you should be doing. using marc's
example you just need to loop through all the elements of your form
using an index, 'i'. not the name of the element which would be "zip1".

>       if(document.memberform.zip[i] = "")
                               ^
                               |
so when you get down to this line. you are sort of saying
'if(document.memberform.zip1[1] = "")' which wouldn't work.

according to marc's example i think it should look like this...

-----------------------------
if(document.memberform.elements[i] = "") {
	then do something...
} else {
	something else...
}
-----------------------------

i'm no javascript person, and in fact i've probably done it all wrong!
so let's just wait and hear what marc has to say about it!

(i just thought i'd chime is all.)

;)
chris.

p.s. and then again there's that checking for .type and all too. but i'm
not sure how to do that.



More information about the thelist mailing list