How to append multiple values to a single parameter in html form?
html, jquery, php
Solution
If you want several values in one parameter, you have to name it like `parameter[]`
f.e.:
<form action="process.php">
<input type="checkbox" name="parameter[]" value="oats"> Oats
<input type="checkbox" name="parameter[]" value="beans"> Beans
<input type="hidden" name="parameter[]" value="a"/>
<input type="submit" value="Submit"/>
</form>
Problem
Assuming I have the following form: ``` <form action="process.php"> <input type="checkbox" name="option1" value="oats"> Oats <input type="checkbox" name="option2" value="beans"> Beans <input type="hidden" name="parameter" value="a"/> <input type="submit" value="Submit"/> </form> ``` What would normally happen is after clicking on the URL, the browser redirects to: ``` process.php?option1=oats&option2=beans¶meter=a ``` How do I make it such that when the submit is clicked all the checkboxes end up as part of the "parameter", but separated by commas? So in other words it would be: ``` process.php?parameter=a,oats,beans ``` Best solution with minimal javascript/jquery/html is best if no html solution.