jquery - Javascript create array using foreach checkbox values -


ok guys have form

<input id="valor" name="valor[]" type="checkbox" value="1" /> <input id="valor" name="valor[]" type="checkbox" value="2" /> <input id="valor" name="valor[]" type="checkbox" value="3" /> <input id="valor" name="valor[]" type="checkbox" value="4" /> <input id="valor" name="valor[]" type="checkbox" value="5" /> <input id="valor" name="valor[]" type="checkbox" value="6" />  <input id="result" name="result" type="text" /> 

what need is:

when check of checkboxes array format (for example)

1|2|4

is updated in real time inside result text field, can use in php explode tryed lot of thins none works

ps. passing trough post not enough know if post field gonna have array need pass result field

thanks in advance

you execute serialize() function on form wraps these checkboxes. resulting string can "decoded" in php using parse_str() function.

a serialized string of checkboxes being selected this:

valor%5b%5d=1&valor%5b%5d=2&valor%5b%5d=3&valor%5b%5d=4&valor%5b%5d=5&valor%5b%5d=6 

passing value though parse_str() give similar this:

[valor] => array     (         [0] => 1         [1] => 2         [2] => 3         [3] => 4         [4] => 5         [5] => 6     )      

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -