title: Checking & Unchecking Checkboxes inside a JQuery Mobile Dialog
body: <p>I tried this code to achieve what I want to do. It worked when I tried it in my ordinary HTML file, but when I tried it in my JQuery Mobile page, the code did not work well for me. Are there different ways or code to select JQuery Mobile checkboxes?</p>
  
  <p>Here's the code that I tried:</p>
  
  <p>JAVASCRIPT:</p>
  
  <pre><code>&lt;script&gt;
  function SetAllCheckBoxes(FormName, FieldName, CheckValue)
  {
      if(!document.forms[FormName])
          return;
      var objCheckBoxes = document.forms[FormName].elements[FieldName];
      if(!objCheckBoxes)
          return;
      var countCheckBoxes = objCheckBoxes.length;
      if(!countCheckBoxes)
          objCheckBoxes.checked = CheckValue;
      else
          // set the check value for all check boxes
          for(var i = 0; i &lt; countCheckBoxes; i++)
              objCheckBoxes[i].checked = CheckValue;
  }
  </code></pre>
  
  <p></p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form method="GET" name="myForm" onsubmit="return false;"&gt;
  &lt;label for="myCheckbox1"&gt;
      &lt;input type="checkbox" name="myCheckbox" value="1" id="myCheckbox1"&gt;
      I like Britney Spears 
  &lt;/label&gt;
  &lt;br&gt;
  
  &lt;label for="myCheckbox2"&gt;&lt;input type="checkbox" name="myCheckbox" value="2" id="myCheckbox2"&gt;
      I like Hillary Duff
  &lt;/label&gt;
  &lt;br&gt;
  
  &lt;label for="myCheckbox3"&gt;&lt;input type="checkbox" name="myCheckbox" value="3" id="myCheckbox3"&gt;
      I like Mandy Moore 
  &lt;/label&gt;
  &lt;br&gt;
  
  &lt;input type="button" onclick="SetAllCheckBoxes('myForm', 'myCheckbox', true);" value="I like them all!"&gt;
  &amp;nbsp;&amp;nbsp;
  &lt;input type="button" onclick="SetAllCheckBoxes('myForm', 'myCheckbox', false);" value="I don't like any of them!"&gt;
  </code></pre>
  
  <p></p>