[thelist] testing for empty in javascript or vbscript
Tom Dell'Aringa
pixelmech at yahoo.com
Mon Jul 15 19:57:03 CDT 2002
Actually, no.
the eval() function is WAY WAY overused by programmers. Danny Goodman
says if you are using eval(), you need to find a better way of doing
things. Some people say if you are using eval, you are just being
lazy (that might be a bit harsh ;))
Anyway, load this up:
-----------------------
<html>
<head>
<title>Untitled</title>
<script>
i = 2
zip = "zip" + i;
function x() {
alert(document.getElementById(zip).value);
}
</script>
</head>
<body onload="x();">
<form>
<input type="text" id="zip2" value="fun">
</form>
</body>
</html>
-----------------------
You'll see that zip indeed does work a doc reference. Its merely a
string, and all getElementById wants as a parameter is a string of an
object.
Tom
--- Marc Seyon <seyon at delime.com> wrote:
> Message from Tom Dell'Aringa (7/15/2002 05:17 PM)
> >Actually, no - this should work, thanks to JS loose types. Do this
> in
> >a blank document.
> >
> ><script>
> >i = 2
> >zip = "zip" + i;
> >document.write(zip)
> ></script>
> >
> >change i to whatever you want. You will get zip2 or whatever
> number
> >you input.
>
> You will get "zip1" or "zip2" as a string. I think what Shashank
> means is
> you will need the eval() function to convert that string to a
> variable name.
>
> Right?
> -m
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !
=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/
__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com
More information about the thelist
mailing list