javascript - How to set value in p tag using jq? -
i trying search bank name onkeyup , want put result in p tag it's not happening. can me anyone?
this jq : //search bank name
$('input[name^="acc_voucher_bank[]"]').live('keyup',function(){ var acc_voucher_bank=$(this).val(); $(this).closest('tr').find('p.banknameresult').show(); $.post("../accounting_model/cash_receive_daily_date_wise.php",{ acc_voucher_bank:acc_voucher_bank, rand:math.random() },function(data){ $(this).closest('tr').find('p.banknameresult').html(data); }) })
html code :
<table width="100%" id="mytable"> <tr class="tr_view"> <td style="width:25%;">bank name</td> <td style="width:30%;">branch name</td> <td style="width:15%;">a/c. no</td> <td style="width:15%;">amount</td> <td style="width:15%;">action</td> </tr> <tr class="bg1" style="text-align:center;"> <td> <input type="text" style="width:200px;" name="acc_voucher_bank[]" id="" placeholder="bank name" /> <p id="banknameresult" class="banknameresult" name="banknameresult[]" style="position:absolute; margin:0px;"></p> <input type="hidden" name="bank_id[]" id="" /> </td> <td> <input type="text" style="width:270px;" name="acc_voucher_branch[]" id="" placeholder="branch name" /> <p id="bankbranchnameresult" class="bankbranchnameresult" name="bankbranchnameresult[]" style="position:absolute; margin:0px;"></p> <input type="hidden" name="bank_branch_id[]" id="" /> </td> <td> <input type="text" style="width:130px;" name="acc_bank_account_number[]" id="" placeholder="a/c no" /> <p id="bankaccountresult" class="bankaccountresult" name="bankaccountresult[]" style="position:absolute; margin:0px;"></p> <input type="hidden" name="bank_account_no[]" id="" /> </td> <td><input type="text" style="width:130px;" name='bank_amount[]' id="" placeholder="amount" /></td> <td><input type="button" value="+" class="addtr" /></td> </tr> </table>
that's because this
inside $.post
callback function jquery xhr object. can assign element want change variable, won't changed inside $.post
callback:
$('input[name^="acc_voucher_bank[]"]').live('keyup',function(){ var acc_voucher_bank=$(this).val(); $element = $(this).closest('tr').find('p.banknameresult'); $element.show(); $.post("../accounting_model/cash_receive_daily_date_wise.php",{ acc_voucher_bank:acc_voucher_bank, rand:math.random() },function(data){ $element.html(data); }) })
Comments
Post a Comment