Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm just going to give you a hint on how to catch up the checked checkboxes once the form is submitted (<a href="http://jsfiddle.net/uEQVC/11/" rel="nofollow"><strong>DEMO</strong></a>).</p> <p>Imagine you have the following html:</p> <pre><code>&lt;form id="testForm"&gt; &lt;input class="checkbox" name="one" type="checkbox"&gt; &lt;input class="checkbox" name="two" type="checkbox"&gt; &lt;input class="checkbox" name="three" type="checkbox"&gt; &lt;input type="hidden" name="checkboxStr" id="checkbox_str"&gt; &lt;button&gt;Send&lt;/button&gt; &lt;/form&gt; </code></pre> <p>You can add an event listener to form submission:</p> <pre><code>var form = document.getElementById('testForm'); try { form.addEventListener("submit", submitFn, false); } catch(e) { form.attachEvent("onsubmit", submitFn); //IE8 } </code></pre> <p>And then you can get all the needed checkboxes with for example its class name. Loop trough them and add the checked ones to an array which you later on join to a string.</p> <pre><code>function submitFn(event) { event.preventDefault(); var boxes = document.getElementsByClassName('checkbox'); var checked = []; for(var i=0; boxes[i]; ++i){ if(boxes[i].checked){ checked.push(boxes[i].name); } } var checkedStr = checked.join(); document.getElementById('checkbox_str').value = checkedStr; form.submit(); return false; } </code></pre> <p>You can now send this string via ajax or you can add a hidden form field and set the string as its value and submit the form without ajax.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload