It is not valid to have two entries with the same name. If you want to do this, you can use <input name="titles[]">
You can try the following:
<input name="titles[]"> <input name="titles[]"> β<button>submit</button>βββββββββββββββββββββββ
Using this jQuery
// click handler function onClick(event) { var titles = $('input[name^=titles]').map(function(idx, elem) { return $(elem).val(); }).get(); console.log(titles); event.preventDefault(); } // attach button click listener on dom ready $(function() { $('button').click(onClick); });
See how it works here on jsFiddle
EDIT
This answer gives you headers in an array instead of a string, using a separator |
. Personally, I think this is much more convenient.
If you just submit the form and want to support multiple values, use the .serialize
method as described in another answer
source share