javascript - Save user input in Array -


i true beginner in html/js/jquery.

i trying save user input array, later want write information array xml file.

my problem form consists of multiple jobs have same input fields.

this short example of first job:

<form>     <table class="wrapper">         <tr>             <td style="text-align: left">first digit:             <div> <input id="fdigit" type="text" name="job1[]" /></td>             <td style="text-align: left">system:                   <div> <input id="system" type="text" name="job1[]" /></td>             <td style="text-align: left">sap modul:               <div> <input id="sapmodul" type="text" name="job1[]" /></td>         </tr>         <tr>             <td style="text-align: left">country:              <div> <input id="country" type="text" name="job1[]" /></td>             <td style="text-align: left">duration:              <div> <input id="duration" type="text" name="job1[]" /></td>             <td style="text-align: left">step number:              <div> <input id="stepnumber" type="text" name="job1[]" /></td>         </tr>         <tr>             <td style="text-align: left">optional text:                 <div>                  <textarea align ="left" id ="optionaltext" name="job1[]" cols="20" rows="2"> </textarea>                 </div>             </td>         </tr>     </table> </form> 

i have many more of in script.

what want saving information of every job array, meaning job1[]: user input of every field shown above , job2[]: different user input similar input field same name. there might easier solution can't figure 1 out.

sorry if stupid issue tried find solutions ages , not find 1 helped me out.

thanks in advance!

for beginner, easiest solution might use component form serialization you. form should have name (attribute), , id going useful too.

i've found form2js practical, , can manage collecting named fields array.

i made small fiddle shows 1 way collect info yourself, example this.

var job1 = []; $('[name="job1[]"]').each(function(index, inputfield) {     job1.push($(inputfield).val()); }); console.log(job1); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -