How to get input text value from specific row using Jquery

T3hReaper

New Member
Hello all this is the page that i currently building:
rqaes.png
When click Submit, I get the text value in the current row and submitted via jquery ajax. There is no problem for me, but when is I test in another pc in the network there are error message appear (via json). Something like the annual leave and sick leave is undefined.Example of error in other pc that i tested:
JQLdn.png
This is the code that i use:\[code\]function popUpReasonApplyLeave(){$('a.submit').bind('click', function(e) { e.preventDefault(); //get the tr row id you have clicked var trid = $(this).closest('tr').attr('id'); $('#pop_up_apply_leaveReason').show(); submitReason(trid); //when submit call the ajax function here});}\[/code\]The data in the ajax function\[code\]data : { idstaff : trid, annualleave : $('#'+trid+' input#annualleave').val(), sickleave : $('#'+trid+' input#sickleave').val(), reason : $('#reason').val(),}\[/code\]The html table code\[code\]<?php foreach($list as $value) {?> <tr id='staffID_<?php echo $value['IDSTAFFTABLE']; ?>'> <td><?php echo $value['FIRSTNAME']; ?> <?php echo $value['LASTNAME']; ?></td> <td><?php echo $value['POSITIONNAME']; ?><input type="hidden" id="idstaff" name="idstaff" value="http://stackoverflow.com/questions/3616548/<?php echo $value['IDSTAFFTABLE']; ?>" /></td> <td><input type="text" name="annualleave" class="annualleave" value="http://stackoverflow.com/questions/3616548/<?php echo $value['ANNUALLEAVEBALANCE']; ?>" id="annualleave"/></td> <td><input type="text" name="sickleave" class="sickleave" value="http://stackoverflow.com/questions/3616548/<?php echo $value['SICKLEAVEBALANCE']; ?>" id="sickleave"/></td> <td><a href="http://stackoverflow.com/questions/3616548/#"class="submit">Submit</a></td> </tr> <?php } ?>\[/code\]The ajax code\[code\]$.ajax({beforeSend : function(){ $("#submitreason").unbind('click');},type: "POST",async : false,url: "http://192.168.1.5:83/staging/eleave/application/controller/controller.php?action=doupdateleavecontroller",dataType: 'json',data : { idstaff : trid, annualleave : $('#'+trid+' input#annualleave').val(), sickleave : $('#'+trid+' input#sickleave').val(), reason : $('#reason').val(),},success : function(data) { var encoded = $.toJSON(data); var result = $.evalJSON(encoded).msg; $('#pop_up_apply_leaveReason').hide(); alert(result); location.reload();},error : function(XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest + " : " + textStatus + " : " + errorThrown);}}); \[/code\]
 
Back
Top