I've created a VF page and got a input text field referring a campaign field and a checkbox which is not referenced to any object field. So I need help on writing js to disable and enabled the text field when the checbox is checked/unchecked.

any help on this please?


Visualforce allows you to use html tags, so you could use something like this:

<input type="checkbox" onchange="var theTextBox = document.getElementById('{!$Component.theId}'); theTextBox.disabled = theTextBox.disabled ? false : true;" />

Just make sure to switch theId with the actual id of the visualforce inputField component in your page. A good reference on how to refer to Visualforce Ids in javascript can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.