javascript - Convert numerous inputs values into array of values -


i have several textbox below:

<input type="text" id="name1" name="name1"> <input type="text" id="name2" name="name2"> <input type="text" id="name3" name="name3"> <input type="text" id="name4" name="name4"> 

need pass save values in array (name[]) , want receive data "name[]"

the server side file use php $_post['name'] fetch data.

thanks.

one of many solutions can

function myfunction() {   var result = [];   var x = document.queryselectorall("[name^=name]");   (var = 0; < x.length ; i++){     result.push(x[i].value);   } } 

Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -