0

I have a problem here when I update the information, only the 'description' has updated the 'pullout_qty' did not. How can I save the 'pullout_qty' inside the append table? How am I supposed to update the value of 'pullout_qty' here? I see a similar question Pass a javascript variable value into input type hidden value but the input hidden and value are inside the js.

function pullout_edit(x){
              $.post(URL+"index.php/pullout_request/loadPullOutRequestForm",{mode:'edit',pullout_id:pullout_id}).done(function(data){
                $("#dialog1").html(data).dialog("open");

                var description=$('#tbl_description'+x).val();
                $('#form_description').val(description);

                var product_name=$('#tbl_product_name'+x).val();
                var pullout_qty=$('#tbl_pending_pullout_qty'+x).val();

                $('#product_addtostock_toadd tbody').append(`
                    <tr id='tblC_row`+row_cnt+`'>
                    <td>
                    <input type='hidden' id='tblC_visibility`+row_cnt+`' value='1'/>
                    <input type='hidden' id='tblC_qty`+row_cnt+`' value='`+pullout_qty+`'/>
                    <td>`+product_name+`</td>
                    <td><input type='number' style='width:100%; border:none;' id='tblC_qty' min='1' value='`+pullout_qty+`'></td>
                    </tr>
                    `);

                $('#save').append(`
                    <div class='col-sm-12' align='right'>
                    <button class='btn btn-success' onclick='update_save();'><span class='glyphicon glyphicon-save'></span> Update Request</button>
                    </div>
                    `);

}  //end edit

After saving the value of 'pullout_qty' becomes zero.

function update_save(){
        var cnt=parseInt($('#form_addstockcnt').val());

        var description=$('#form_description').val();
        var pullout_qty=[];
                        var z=0;
                        for(var x=0;x<cnt;x++){
                            if($('#tblC_visibility'+x).val()==1){                   
                                pullout_qty[z]=$('#tblC_qty'+x).val();
        z+=1;
    }
} 


        $.ajax({url:URL+"index.php/pullout_request/loadEditSave",
          method:"POST",
          data:{
            pullout_qty:pullout_qty,
            description:description,
        },
        success:function(data){
            SYS_pending_setlist();   
            setTimeout(function(){
                $("#dialog1").dialog("close");     
            },500);
        },
        error:function(err){
            console.log(err);
        }
    });
}  // end 
5
  • Maybe nothing with the id tbl_pending_pullout_qty exists. Try adding alert(pullout_qty) to check the value Commented Jan 8, 2020 at 2:57
  • It has value. I think the problem is inside the append() Commented Jan 8, 2020 at 3:17
  • I see a similar question stackoverflow.com/questions/7764154/… Commented Jan 8, 2020 at 3:18
  • Sorry I can not understand the relevance of two JS methods? Which one is wrong? Commented Jan 8, 2020 at 3:26
  • I solved it now. The problem was in update_save(). It should be var pullout_qty=$('#tblC_qty').val(); Commented Jan 8, 2020 at 3:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.