Tech Programing


save table value to array to be pass in class in javascript

1 min read

I want to save table details to array then send it to class for saving. I was able to get the details from rows but the details combine. See below (I will just show the function involve)

AddRushRef: function (rushtype, rushref, datereported){
   var tdbody = $("#tblRushRef tbody")
   var tdrushtype = "<td style="" name="RushType" class="rushtype">" + rushtype +"</td>";
   var tdref = "<td style="" name="References" class="rushref">" + rushref +"</td>";
   var tddate = "<td style="" name="RushType" class="rushdate">" + datereported +"</td>";
   tdbody.append("<tr>" + tdrushtype + tdref + tddate  "</tr>");

GetRushReferences: function() {
   var rows = $("#tblRushRef tbody > tr");
   var temp = [];

   $.each(rows, function() {   
      var rushtype = rows.find(".rushtype").text();
      var rushref= rows.find(".rushref").text();
      var rushdate = rows.find(".rushdate").text();

        RushType: rushtype, 
        ReferenceNo: rushref,
        DateReported: rushdate
   return temp;

Submit: function () {
   var toSubmit = {
      References: mypage.GetRushReferences() //this is where the datas in`temp` will be pass for saving in DB

These are the sample data inputted:

rushtype: OIR rushref: 12345678901 rushdate: 02/03/2022

rushtype: RFC rushref: 98765432102 rushdate: 02/03/2022

When console.log(temp)


as you can see, all details were combine. Hope you can help me with this.

Thank you

Source link



發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *