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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -