ae*****@gmail.com wrote:
Folks,
I'm writing this command:
form_name.elements[i].property_name = action; //action = true/false
I want to pass the property_name as dynamic value so if the function
passes "disabled" it'll be like:
form_name.elements[i].disabled = true;
I tried to do that with eval but couldn't get it to work!
As usual, there is no need for 'eval' at all. Whenever dot notation
doesn't work, try square brackets:
<script type="text/javascript">
function doThing( thing, prop, value )
{
thing[prop] = value;
}
</script>
<form action="">
<input type="text" name="fred"
<input type="button" value="Disable Fred" onclick="
doThing( this.form.fred, 'disabled', 'true');
">
</form>
--
Rob