title: JavaScript- Clear the value of a checkbox in a hidden section of HTML
body: <p>I have a web form displaying a number of questions. It was recently reported that one of the questions shown in a conditional section of the form was retaining its value when the condition used to display that question was met, then not met, and met again.</p>
  <p>i.e. If the user answered 'Yes' to question 1, questions 1a &amp; 1b would be shown, if they changed their answer to question 1 to 'No', questions 1a &amp; 1b would be hidden, but if they changed their answer to question 1 back to 'Yes', questions 1a &amp; 1b would be shown again with the answers previously given still selected. 1a &amp; 1b should return to blank/ null values once they were hidden &amp; shown again.</p>
  <p>I managed to blank the answers to parts (a) &amp; (b) when hidden and re-shown if (a) &amp; (b) are drop down form elements with the following code:</p>
  <p>However, the form consists of fields of a number of different types, and I'm currently having a bit of trouble getting it to clear the selected options for a list of checkboxes (where selection of multiple checkboxes is possible).</p>
  <p>I tried to clear the selection in a similar way to how I had done for the dropdown:</p>
  <pre><code>var cb = hiddenwrapper.children('select[id^=&quot;checkbox&quot;]');
  cb.checked = false;
  </code></pre>
  <p>However, when I hide &amp; re-show the question with the checkbox answers by selecting 'Yes' &amp; 'No' as the answer to question 1, the previously checked checkboxes are still checked when the question is re-shown.</p>
  <p>The debug I've added to show the value of <code>cb.checked</code> after setting it to false does show that it's value is false, but the checkboxes themselves are actually still checked:</p>
  <blockquote>
  <p>cb:</p>
  <p>checked: false</p>
  <p>length: 0</p>
  </blockquote>
  <p>How can I clear the selected checkboxes when the question is hidden &amp; re-shown?</p>