Thomas Jericho Capuyan Thomas Jericho Capuyan - 6 months ago 19
Javascript Question

How to automatically detect when textbox changes text in my code? TIA

This is my code. How to automatically detect when textbox changes text in my code? TIA

$('input#name').text('content',function() {
var name = $('input#name').val();
if($.trim(name) != ''){
$.post('getphp/getpartnerposition.php', {name: name}, function(data){
$('input#position2').val(data);
});
}
});

Answer

Try following code, it might help you

$('input#name').on('change',function()  {
       var name = $('input#name').val();
       if($.trim(name) != ''){
       $.post('getphp/getpartnerposition.php', {name: name}, function(data){
       $('input#position2').val(data);
     });
}
});
Comments