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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -