Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd value to hidden value by onclick checkbox
    primarykey
    data
    text
    <p>I have a form with some input checkboxes. For example:</p> <pre><code> &lt;input type="checkbox" name="felhasznal_1" id="felhasznal_1" onclick="felhasznal(this)"&gt; &lt;input type="checkbox" name="felhasznal_2" id="felhasznal_2" onclick="felhasznal(this)"&gt; &lt;input type="checkbox" name="felhasznal_3" id="felhasznal_3" onclick="felhasznal(this)"&gt; </code></pre> <p>I have hidden value for a form:</p> <pre><code>&lt;input type="hidden" name="felhasznalas" value=""&gt; </code></pre> <p>My form is named like this:</p> <pre><code> &lt;form method="post" name="ujpartner_ceg" enctype="multipart/form-data" id="ujpartner_ceg"&gt; </code></pre> <p>And I want to add a masked id for the value of felhasznalas. But I have 2 forms with the same inputs, so that's why I named the forms, and I want to access to them by getelementByid using the form name.</p> <p>Here is my javascript (generated by php):</p> <pre><code>function felhasznal() { document.ujpartner_ceges.getElementById('felhasznalas').value = '|x|'; if (document.ujpartner_ceges.getElementById('felhasznal_1').checked) { document.ujpartner_ceges.getElementById('felhasznalas').value = document.ujpartner_ceges.getElementById('felhasznalas').value + '1|x|'; } if (document.ujpartner_ceges.getElementById('felhasznal_2').checked) { document.ujpartner_ceges.getElementById('felhasznalas').value = document.ujpartner_ceges.getElementById('felhasznalas').value + '2|x|'; } if (document.ujpartner_ceges.getElementById('felhasznal_3').checked) { document.ujpartner_ceges.getElementById('felhasznalas').value = document.ujpartner_ceges.getElementById('felhasznalas').value + '3|x|'; } } </code></pre> <p>What did i do wrong? </p> <p>EDIT: I get this error: TypeError: document.ujpartner_ceges is not a function.</p> <p>NOTICE: I have a form with the same inputs named ujpartner_magan!</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. 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