AKEEL AHMED AKEEL AHMED - 11 months ago 84
Javascript Question

Inline JavaScript enable/disable select and text box on click radio button

I am trying inline script to enable disable with radio button, but it is not working. How to do that?

<select id="mySelect">
<input type="radio" name="ph" onclick=" document.getElementById("mySelect").disabled=true;" value="Disable list">DISABLE
<input type="radio" name="ph" onclick="enable()" value="Enable list">ENABLE


You can even see it at the syntax highlighter. Your JavaScript in the onclick event contains ", but they're special characters for HTML. You have to escape them with backslashes like

<tag onclick="alert(\"hello\");">