javascript eval problem - should be easy

admin

Administrator
Staff member
I can not seem to get this code to work correctly...

If i hardcode the element name in the first alert, it works.
If i try to pass the variable, it doesn't. What's wront with the syntax...

By the way, the variable references a form element that is a radio box and it has up to 4 values.


newchoice ="LittlePleasure";

// works
alert ("value hardcoded: " + eval(document.all.LittlePleasure[3].checked));

// doesn't work
alert ("value var passed: " + eval(document.all.newchoice[3].checked));
 
Back
Top