Javascript gurus...

A General Discussion forum for cars and other topics, and a great place to introduce yourself if you are new to NICO!
User avatar
RobDET
Posts: 1553
Joined: Wed May 07, 2003 5:51 pm
Car: Cars

Post

I wanna do this...

function enableField(checkbox,fieldname){ if (checkbox.checked) { document.Form1.(fieldname.value).disabled = false; document.Form1.(fieldname.value).focus(); } else { document.Form1.(fieldname.value).disabled = true; } }

I can't get it to work. I'm sure the syntax is incorrect but the goal is to make the function dynamic. I want to be able to activate any field based on any check box.

The problem is (fieldname.value) doesn't work at all and if you just put .fieldname. it doesn't put the contence of the variable there it just trys to look up the literal object "document.Form1.fieldname" Which doesn't exist.


TrueSlide
Posts: 2126
Joined: Fri Aug 02, 2002 7:07 pm
Car: Stuff

Post

I would assume your problem is lies here:if (checkbox.checked)

what is checkbox.checked suppose to equal, true? false? 1? 200000?

User avatar
RobDET
Posts: 1553
Joined: Wed May 07, 2003 5:51 pm
Car: Cars

Post

that part works... i've tested it... it returns a ture/false value.


Return to “General Chat”