[Javascript] variable problem

Peter Brunone peter at brunone.com
Thu Jun 7 09:17:58 CDT 2001


    The whole purpose of the eval() function is to take a string (line of
letters,numbers, or whatever) that you build and convert it to a JavaScript
variable reference.  Otherwise, you are just building a string -- like
"mynameisBob" -- and telling the script engine that it should know what to
do with it.  This is a fundamental concept of programming in all languages,
the difference between variables and string expressions.
    Several people on this list have recommended Danny Goodman's JavaScript
Bible for those who wish to learn about JavaScript; you might want to check
into that, and/or into some of the many sites listed at
http://www.mountaindragon.com/javascript/resources.htm .

Cheers,

Peter

----- Original Message -----
From: <rastlore at yahoo.ca>
To: <Javascript at LaTech.edu>
Sent: Thursday, June 07, 2001 8:56 AM
Subject: [Javascript] variable problem


> Hello,  I am having a problem, I am a newbie at this javascript stuff
> by the way.  I was wondering why the below works (more specifically I
> am asking about the variables "i" and "j" why it works in the eval
> and not in the other statement is my question) :
>
> if (eval("document.game_assesment.row"+ i +"_"+ j +".checked") ==
> true)
>
> but this give me an error :
> document.game_assesment.row"+ i +"_"+ j +".checked = true;
>
> I have also tried this, but it gives and error as well :
> document.game_assesment.row'+ i +'_'+ j +'.checked = true;
>
> The button's I am tried to access is :
>
> <FORM NAME="game_assesment">
> <INPUT type="radio" NAME="row0_0" VALUE="0">
> <INPUT type="radio" NAME="row0_1" VALUE="0">
> <INPUT type="radio" NAME="row0_2" VALUE="0">
> </FORM>
>
> Thanks for any help you could offer.
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list