Javascript enable textfield on checkbox tick
I have this HTML Code:
<input type="checkbox"
onclick="document.getElementById('directory_entry_name').disabled=this.checked;"
name="directory_entry" id="directory_entry" />
<strong>Name: </strong><input type="text" name="directory_entry_name"
id="directory_entry_name" disabled="disabled" />
so the text box is disabled and im trying to make it so when the checkbox
it ticked, it will enable the text box and when it is unchecked again it
will disable the textbox.
it works if i use:
<input type="checkbox"
onclick="document.getElementById('directory_entry_name').disabled=false;"
name="directory_entry" id="directory_entry" />
but then when it is unchecked it doesnt re-disable the textbox.
No comments:
Post a Comment