Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery get multiple input values by name

<input name="titles[]">
<input name="titles[]">
<button>submit</button>

// 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);
});
 
PREVIOUS NEXT
Tagged: #jquery #multiple #input #values
ADD COMMENT
Topic
Name
8+8 =