eval is an important function as it allows you build Javascript dynamically |
For instance document.forms[0].actualtextname.value is value of form element specified as |
<INPUT TYPE="text" NAME="actualtextname" VALUE="value" onChange="handle(this.name)" > |
this.name holds actualtextname but as an ascii string which cannot be directly be used in |
var x = document.forms[0].actualtextname.value; |
var x = eval("document.forms[0]." + actualtextname + ".value"); // works! |
eval applies JavaScript interpreter to argument and then re-interprets as shown above |
This can be used to copy information between forms as in |
eval("document.forms[1]." + actualtextname + ".defaultvalue") = eval("document.forms[0]." + actualtextname + ".value") |
eval did not work properly for a long time! -- Please check on your browser |