AKEEL AHMED AKEEL AHMED - 1 year ago 134
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

Answer Source

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\");">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download