Reputation: 77
Let me start by saying I am new to using jQuery so this may seem like a dumb question. When the vin textbox focuses out it trigers the jQuery script to run.
$("#vin").focusout(function() {
$("#stocknum").load("../jquery/update_stocknum.php?vin=" + $("#vin").val());
});
The PHP file is as follows and appears to be running correctly:
if(isset($_GET['vin'])){
$vin = $_GET['vin'];
if(strlen($vin) > 9) {
$stocknum = substr($vin,-6);
echo $stocknum;
}
What am i doing wrong so that I can set the value of the textbox to the what php is returning in the variable $stocknum?
Thanks in advance for your help!
Upvotes: 1
Views: 284
Reputation: 44740
Try -
$("#vin").focusout(function() {
$.get("../jquery/update_stocknum.php?vin=" + $("#vin").val(),function(data){
$("#stocknum").val(data);
});
});
Upvotes: 1