Load table contents from above with jquery (multiple lines)

Asked 2 years ago, Updated 2 years ago, 128 views

Read the table on the modal in jquery and
I would like to have some columns read in template on html.
For now, I thought I could load it with each.
Only the last line of the table was loaded.
   This is a reference URL.
Number elements in order of jquery

// code
function allsave(){
  varmtllgh=$("#mtlctbody").child().length;
  $("#mtlctr").each(function(){
    $(this).children().each(function(i){
      v1 = $('[name=m-name] option: selected').text();
      v2 = $('[name=m-num] option: selected').text();
      var resultone = {
        val1:",
        val2: ",
        val3: ",
        val4: ",
        val5: ",
        val6: ",
        val7: v1 + " + v2,
        val8:$('#hm').val(),
        val9: $('.size 1').val() + "x" + $('.size 2').val() + "+$('.kazu') .val() + "pcs"
      }
      var result={
        val1:",
        val2: ",
        val3: ",
        val4: ",
        val5: ",
        val6: ",
        val7: v1 + " + v2,
        val8:$('#hm').val(),
        val9: $('.size 1').val() + "x" + $('.size 2').val() + "+$('.kazu') .val() + "pcs"
      }
      if(i!=0){
        $("#showltbl1").html(addmtbl(result)));
      } else {
        $("#showltbl1").html(addmtbl(resultone)));
      }
      i = i+1;
    });
  });
}
//

html jquery twitter-bootstrap

2022-09-30 16:24

1 Answers

I don't know what addmtbl() is doing, but if addmtbl() is a function that simply returns a string,
.html (addmtbl(result)) overwrites the string returned by addmtbl(result) in the element.

To add while spinning, use .append.
Example $("#showltbl1").append(addmtbl(result)));

$(function(){
        $('#ow1').on('click', function(){
            $("#showltbl1").html('<p>overwrite</p>');
        })
        $('#ad1').on('click', function(){
            $("#showltbl1").append('<p>add</p>');
        })
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button id="ow1">Overwrite</button><button id="ad1">Add</button>
<divid="showltbl1"></div> 


2022-09-30 16:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.