Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You retrieve <code>.value</code> from the same object you retrieved <code>.checked</code> from:</p> <pre><code>valore_corrente = vettore[i].value; </code></pre> <p>The object is an <a href="http://www.w3.org/TR/html5/forms.html#htmlinputelement" rel="nofollow"><code>HTMLInputElement</code></a> instance. The value of the checkbox is reflected in the <code>value</code> property, just like whether it's checked is reflected in the <code>checked</code> property.</p> <p>Here's a complete, working example: <a href="http://jsbin.com/uVEvOrU/1" rel="nofollow">Live Copy</a> | <a href="http://jsbin.com/uVEvOrU/1/edit" rel="nofollow">Source</a></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=utf-8 /&gt; &lt;title&gt;Example&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="theform"&gt; &lt;label&gt;&lt;input type="checkbox" value="1" checked&gt;Uno&lt;/label&gt; &lt;br&gt;&lt;label&gt;&lt;input type="checkbox" value="2" checked&gt;Due&lt;/label&gt; &lt;br&gt;&lt;label&gt;&lt;input type="checkbox" value="3"&gt;Tre&lt;/label&gt; &lt;br&gt;&lt;input type="button" id="thebutton" value="Click"&gt; &lt;/form&gt; &lt;script&gt; document.getElementById("thebutton").onclick = function() { var id_form = "theform"; var vettore = document.getElementById(id_form).elements; var contatore = 0; var valore_corrente; var stringaFileSelezionati = ""; for (var i = 0; i &lt; vettore.length; i++) { if (vettore[i].checked) { contatore++; valore_corrente = vettore[i].value; stringaFileSelezionati+= valore_corrente; stringaFileSelezionati+= '?'; } } if (contatore == 0) { alert('Error!!! No file selected!'); return false; } else { alert(stringaFileSelezionati); } }; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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. 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.
 

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