Pushing arrays based on each row inputs dynamically

后端 未结 3 961
遇见更好的自我
遇见更好的自我 2021-01-27 05:32

Based on my code I want to push each row\'s inputs to each array. If it is row1, it should push all the input values of row 1 to array a1. The second row\'s inputs

3条回答
  •  -上瘾入骨i
    2021-01-27 05:34

    I think you mean this.

    I tried to stay as close to your code as possible to not scare you off JavaScript

    $('#check').click(function(event){
      event.preventdefault;
      var a=[];
      $("[id^=row]").each(function() { // for each row
        var idx = a.length; // find how many entries in a
        a[idx]=[]; // add a new array
        $(this).find("td input").each(function(i) { a[idx].push(this.value); }); // fill the array
      });  
    
      var output = ""; // initialise a string
      for (var i=0;iPushed arrays:'+output);
    });
    
    
    1
    1

提交回复
热议问题