Name

eval() — NN 2 IE J1 ECMA 1

Synopsis

eval(string)

Returns an object reference of the object described as a string in the parameter of the function. For example, if a form has a sequence of text fields named entry1, entry2, entry3, and so on, you can still use a for loop to cycle through all items by name if you let the eval() function convert the string representation of the names to object references:

for (var i = 1; i <=5; i++) {
    oneField = eval("document.forms[0].entry" + i)
    oneValue = oneField.value
    ...
}

Returned Value

Object reference.

Parameters

string

Any string representation of an object reference.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.