title: checkbox checked - assign value to variable and send in a submit
body: <p>I have this piece of code, and I'm trying to assign a value to variable <code>days</code> (if one of the combinations of checkbox checked are true), and send by submit to another asp.</p>
  <p>The problem is that the variable doesn't take any value. Here's the code:</p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
  function validatedays(days) {
  var dias=3
  if(document.getElementById(&quot;chkmonday&quot;).checked &amp;&amp; document.getElementById(&quot;chktuesday&quot;).checked) 
      { var days=1;}
  if(document.getElementById(&quot;chkwednesday&quot;).checked &amp;&amp; document.getElementById(&quot;chkthursday&quot;).checked)
      { var days=2;}
  if(document.getElementById(&quot;chkfriday&quot;).checked) {
      var days=3 }
  datos.submit()
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method=&quot;post&quot; id=&quot;data&quot; name=&quot;data&quot; action=&quot;blabla.asp&quot;&gt;
  &lt;input type=&quot;text&quot; name=&quot;txtsurname&quot;  id=&quot;txtsurname&quot; size=&quot;20&quot; /&gt;&lt;br /&gt;
  &lt;input type=&quot;text&quot; name=&quot;txtcuota&quot; id=&quot;txtcuota&quot; size=&quot;20&quot; /&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;input type=&quot;checkbox&quot; value=&quot;chklunes&quot; name=&quot;chkmonday&quot; /&gt;&lt;br/&gt;
  &lt;input type=&quot;checkbox&quot; value=&quot;chkmartes&quot; name=&quot;chktuesday&quot; /&gt;&lt;br/&gt;
  &lt;input type=&quot;checkbox&quot; value=&quot;chkmiercoles&quot; name=&quot;chkwednesday&quot; /&gt;&lt;br/&gt;
  &lt;input type=&quot;checkbox&quot; value=&quot;chkjueves&quot; name=&quot;chkthursday&quot; /&gt;&lt;br/&gt;
  &lt;input type=&quot;checkbox&quot; value=&quot;chkviernes&quot; name=&quot;chkfriday&quot; /&gt;&lt;br/&gt;
  &lt;br/&gt;
  &lt;input type=&quot;submit&quot; value=&quot;Calcular&quot; onclick=&quot;javascript:validatedays(days)&quot; /&gt;  
  &lt;input type=&quot;reset&quot; value=&quot;Clean&quot; /&gt; 
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>