title: Save result checkboxes checked in form into sqlite database with javascript
body: <p>I have a form in my app with several checkboxen. I want the result(value) of the checked checkedboxes saved into separate rows in the database, see below. The problem is that when saving, only the first one (Ma) is saved and the other ones not eventhough the are checked in the form. When MA is not checkend nothing happens at all... I use JqueryMobile/JavaScript/PhoneGap Build</p>
  
  <p>Form:</p>
  
  <pre><code>&lt;form name="test"&gt; 
  &lt;label class="label_check" id="l1" for="ch1"&gt;Ma
  &lt;input class="custom" type="checkbox" name="checkgroup" id="ch1" value="Ma" /&gt;
  &lt;/label&gt;
  &lt;label class="label_check" id="l2" for="ch2"&gt;Di
  &lt;input class="custom" type="checkbox" name="checkgroup" id="ch2" value="Di" checked /&gt;
  &lt;/label&gt;
  &lt;label class="label_check" id="l3" for="ch3"&gt;Woe
  &lt;input class="custom" type="checkbox" name="checkgroup" id="ch3" value="Woe" /&gt;
  &lt;/label&gt;
  &lt;label class="label_check" id="l4" for="ch4"&gt;Do
  &lt;input class="custom" type="checkbox" name="checkgroup" id="ch4" value="Do" /&gt;
  &lt;/label&gt;
  &lt;label class="label_check" id="l5" for="ch5"&gt;Vr
  &lt;input class="custom" type="checkbox" name="checkgroup" id="ch5" value="Vr" checked /&gt;
  &lt;/label&gt;
  &lt;label class="label_check" id="l6" for="ch6"&gt;Za
  &lt;input class="custom" type="checkbox" name="checkgroup" id="ch6" value="Za" /&gt;
  &lt;/label&gt;
  &lt;label class="label_check" id="l7" for="ch7"&gt;Zo
  &lt;input class="custom" type="checkbox" name="checkgroup" id="ch7" value="Zo" /&gt;
  &lt;/label&gt;
  &lt;/form&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;input type="button" name="saveData" id="btn1" value="Save" onclick="saveRecordSafety();"/&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>function saveRecordSafety() {
  //Write the record to the database
  theDBbeter.transaction(insertRecordSafety, onTxErrorB, onTxSuccessB);
  }
  
  function insertRecordSafety(txb) {
  var elementen = document.getElementsByName ("checkgroup");
  var tmpChoise;
  for (var r= 0; r &lt; elementen.lenght; r++);
  if (elementen[r].checked) {
  tmpChoise = elementen[r].value; 
  alert(tmpChoise);
  var sqlStrB = 'INSERT INTO testSafetyBeter (beter) VALUES (?)';
  txb.executeSql(sqlStrB, [tmpChoise], onSqlSuccess, onSqlError);
  }
  }
  </code></pre>