Note that there are some explanatory texts on larger screens.

plurals
  1. POdocument.myform.checkbox.checked without a form
    primarykey
    data
    text
    <p>i know that what i mentioned on the question (above) isn't possible, but i have a problem here, i have double tripe and so on, forms inside a page, and i need to submit a form that gets all the data inside the previous forms.</p> <p>WARNING: I started with javascript like 3 or 4 days ago, i am used to the server-side programming.</p> <p>Let's see:</p> <p>javascript checks if checkboxes are checked (Several of them):</p> <pre><code>function KeepCount() { var NewCount = 0; if (document.iphone3g.iphone3g1.checked) {NewCount = NewCount + 1;} if (document.iphone3g.iphone3g2.checked) {NewCount = NewCount + 1;} if (document.iphone3g.iphone3g3.checked) {NewCount = NewCount + 1;} if (document.iphone3g.iphone3g4.checked) {NewCount = NewCount + 1;} if (document.iphone3gs.iphone3gs1.checked) {NewCount = NewCount + 1;} if (document.iphone3gs.iphone3gs2.checked) {NewCount = NewCount + 1;} if (document.iphone3gs.iphone3gs3.checked) {NewCount = NewCount + 1;} if (document.iphone3gs.iphone3gs4.checked) {NewCount = NewCount + 1;} if (document.iphone4.iphone41.checked) {NewCount = NewCount + 1;} if (document.iphone4.iphone42.checked) {NewCount = NewCount + 1;} if (document.iphone4.iphone43.checked) {NewCount = NewCount + 1;} if (document.iphone4.iphone44.checked) {NewCount = NewCount + 1;} if (NewCount &gt; 1){ descontox = 20/100; valorx = (total.value * descontox).toFixed(2); valor.value = (total.value - valorx).toFixed(2); } if (NewCount &lt;= 1){ valor.value = ("");} } </code></pre> <p>This tells me if a discount should be applied or not, if more than one checkbox is selected it will apply a 20% discount.</p> <p>If you notice, i have several "if (document.iphone3g.iphone3g1.checked) { do something} that interacts with this:</p> <pre><code> &lt;div id="one" class="hiddenDiv"&gt; &lt;div class="image"&gt; &lt;img class="large" src="images/iphone3g.png" alt="iphone3g" width="141" height="141" /&gt; &lt;/div&gt; &lt;form name="iphone3g"&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone3g1" value="50.00"&gt; Vidro Partido&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone3g2" value="59.00"&gt; LCD Danificado&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone3g3" value="80.00"&gt; Substituir capa traseira&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone3g4" value="38.00"&gt; Botão Volume &lt;/form&gt; &lt;/div&gt; &lt;div id="two" class="hiddenDiv"&gt; &lt;div class="image"&gt; &lt;img class="large" src="images/iphone3gs.png" alt="iphone3g" width="141" height="141" /&gt; &lt;/div&gt; &lt;form name="iphone3gs"&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone3gs1" value="60"&gt; Vidro Partido 3GS&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone3gs2" value="69"&gt; LCD Danificado 3GS&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone3gs3" value="89"&gt; Substituir capa traseira 3GS&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone3gs4" value="45"&gt; Botão Volume3GS &lt;/form&gt; &lt;/div&gt; &lt;div id="three" class="hiddenDiv"&gt; &lt;div class="image"&gt; &lt;img class="large" src="images/iphone4.png" alt="iphone3g" width="141" height="141" /&gt; &lt;/div&gt; &lt;form name="iphone4"&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone41" value="169"&gt; Vidro/LCD Partido&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone42" value="99"&gt; Substituir capa traseira&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone43" value="79"&gt; Botão Volume&lt;br /&gt; &lt;input onclick="clickCh(this);KeepCount();" type="checkbox" name="iphone44" value="76"&gt; Botão Home &lt;/form&gt; &lt;/div&gt; </code></pre> <p>I have more than 3 of those, what can i do to solve the question? i need to submit these data to a php file.</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.
 

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