Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>your hidden input has no ID just a name.</p> <p>use <code>&lt;input type="hidden" id="felhasznalas" value=""&gt;</code> instead.</p> <p>The ID must be unique for the DOM (page) not just the form, so if you have several forms you must prefix the control eg: <code>&lt;input type="hidden" id="form1_felhasznalas" value=""&gt;</code>.</p> <p>Then use document.getElementById instead of document.ujpartner_ceges.getElementById.</p> <p>I would also take a couple of hours to learn <a href="http://jquery.com/" rel="nofollow">jquery</a>, it's an amazing javascript-cross-browser-framework / helper for doing things like this :) !</p> <p>Here is a fiddle: <a href="http://jsfiddle.net/3AguQ/" rel="nofollow">http://jsfiddle.net/3AguQ/</a> I have changed the hidden inputs to text so you can se the results...</p> <p>Here is some code:</p> <pre><code>&lt;script&gt; function felhasznal(prefix) { document.getElementById(prefix + '_felhasznalas').value = '|x|'; if (document.getElementById(prefix + '_felhasznal_1').checked) { document.getElementById(prefix + '_felhasznalas').value = document.getElementById(prefix + '_felhasznalas').value + '1|x|'; } if (document.getElementById(prefix + '_felhasznal_2').checked) { document.getElementById(prefix + '_felhasznalas').value = document.getElementById(prefix + '_felhasznalas').value + '2|x|'; } if (document.getElementById(prefix + '_felhasznal_3').checked) { document.getElementById(prefix + '_felhasznalas').value = document.getElementById(prefix + '_felhasznalas').value + '3|x|'; } } &lt;/script&gt; &lt;form method="post" enctype="multipart/form-data"&gt; &lt;input type="hidden" id="form1_felhasznalas" value=""&gt; &lt;input type="checkbox" name="felhasznal_1" id="form1_felhasznal_1" onclick="felhasznal('form1')"&gt; &lt;input type="checkbox" name="felhasznal_2" id="form1_felhasznal_2" onclick="felhasznal('form1')"&gt; &lt;input type="checkbox" name="felhasznal_3" id="form1_felhasznal_3" onclick="felhasznal('form1')"&gt; &lt;/form&gt; &lt;form method="post" enctype="multipart/form-data"&gt; &lt;input type="hidden" id="form2_felhasznalas" value=""&gt; &lt;input type="checkbox" name="felhasznal_1" id="form2_felhasznal_1" onclick="felhasznal('form2')"&gt; &lt;input type="checkbox" name="felhasznal_2" id="form2_felhasznal_2" onclick="felhasznal('form2')"&gt; &lt;input type="checkbox" name="felhasznal_3" id="form2_felhasznal_3" onclick="felhasznal('form2')"&gt; &lt;/form&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.
 

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