How do I use Javascript to change value of a hidden input depending on status of a checkbox?
- 阅读更多 关于 How do I use Javascript to change value of a hidden input depending on status of a checkbox?
问题 I am trying to change the value of a hidden input field, depending on the value of a checkbox. I don't know much about Javascript but this is what I have so far. <input type="hidden" value="" id="delterms" name="O_" /> <input type="checkbox" id="checkbox" onchange="terms()" /> <script type="text/javascript"> var checked = document.getElementById('checkbox').checked; function terms() { if (checked==false) { document.getElementById('delterms').value='' } else { document.getElementById('delterms