Search
 
SCRIPT & CODE EXAMPLE
 

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);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: aos js 
Javascript :: read from s3 bucket nodejs 
Javascript :: add property to string js 
Javascript :: apa itu this pada javascript 
Javascript :: firebase react router page not found on page refresh 
Javascript :: how to detect clicks with javascript 
Javascript :: javascript dataurl to blob 
Javascript :: style react background 
Javascript :: generate random string javascript 
Javascript :: javascript replace last character 
Javascript :: console.log javascript 
Javascript :: isset js 
Javascript :: javascript padend 
Javascript :: js check if element hidden 
Javascript :: iterate through array javascript 
Javascript :: js domtokenlist to array 
Javascript :: lodash get difference between two arrays of objects 
Javascript :: javascript insert last character of string 
Javascript :: create infinite loop using for loop in javascript 
Javascript :: javascript function convert bytes into mb 
Javascript :: passing data variable using ajax 
Javascript :: javascript xmldocument to string 
Javascript :: react native create view dynamically 
Javascript :: how to get date using tolocaledatestring 
Javascript :: Error: `createStackNavigator()` has been moved to `react-navigation-stack`. 
Javascript :: javascript dynamicly include another js file 
Javascript :: react hook toggle state 
Javascript :: javascript every other element in array 
Javascript :: vuejs scroll to top 
Javascript :: replace string in javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =