javascript - Hidden Field Value Not Getting Filled JQuery -


i have html table append using jquery follows fires on button click

$("#listadd").click(function() {       if (validatelistadd()) {          var mcode = $("#mcodehidden").val();          if(checkitemduplicates(mcode)) {             var mname = $("#mnamehidden").val();             var sellprice = $("#sellprice").val();             var cost = $("#cost").val();             var qty = $("#qty").val();             var remark = $("#remark").val();             var subtotal = sellprice * qty;             alert(qty);              $("#productlist tbody").append('<tr  class="sumrow"><td><input id="hdqty" type="hidden" name="tblqty[]" value="' + qty + '"><input id="hdsubtotal" type="hidden" name="tblsubtotal[]" value="' + subtotal + '"><input type="hidden" name="tblmcode[]" value="' + mcode + '">' + mcode + '<input type="hidden" name="tblcost[]" value=' + cost + ' ></td><td><input type="hidden" name="tblmname[]" value="' + mname + '">' + mname  + '</td><td id="tdprice"><input type="hidden" name="tblsellprice[]" value=' + sellprice + '>' + sellprice + '</td><td id="tdqty">' + qty + '</td><td  class="subtotal">' + subtotal + '</td><td><input type="hidden" name="tblremark[]" value=' + remark + '>' + remark + '</td><td><center><button type="button" class="edit" title="edit row"></center></td><td><center><button type="button" class="delete" title="remove row"></center></td></tr>');              $('[id$=mcode]').val("");             $('[id$=mname]').val("");             $('[id$=sellprice]').val("");             $('[id$=qty]').val("");             $('[id$=mcodehidden]').val("");             $('[id$=mnamehidden]').val("");              calculatetotal();         }else{              alert("sorry, have added item");          }      } else {          alert("you have entered invalid data, please check again");      }  }); 

the problem value of hidden field #hdqty not getting filled var "qty" shows value correctly in alert have used in here. when inspected element(table row) in browser, shows hidden field as

<input id="hdqty" type="hidden" name="tblqty[]" value> 

can point me out mistake?

you set value of #hdqty field in string build, below line removes value immediately:

$('[id$=qty]').val(""); 

the selector above matches element has id attribute ends with qty.

remove line, or change selector better fit requirements, , code work.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -