I've got a form where I have two text fields. The first one is an autocomplete field that loads two variables, "item" and "description" via AJAX as a user enters in letters.
What I'm trying to do is the following:
When they click on the item, it populates the field with the item name, but I'd like for it to next populate the adjacent textfield with the description onblur (ie: when the user moves on to another field).
Here's the code:
PHP Code:
$().ready(function() {
$("#item1").autocomplete("model_query.php", {
width: 260,
matchContains: true,
//mustMatch: true,
//minChars: 0,
//multiple: true,
//highlight: false,
//multipleSeparator: ",",
selectFirst: false
});
});
and the PHP script:
PHP Code:
$q = strtolower($_GET["q"]);
if (!$q) return;
$sql = mysql_query("SELECT item as item_name, description from catalog where item LIKE '%$q%'");
while($rows = mysql_fetch_array($sql)) {
$item= $rows ['item_name'];
$descq = $rows ['description'];
echo "$item\n";
}
HTML:
PHP Code:
<div id="content">
<form autocomplete="off">
<p>
ITEM: <input type="text" name="item1" id="item1" />
</div>
These all work for the autocomplete form, but I'm at a loss as to how to move the "$description" variable into the javascript to populate that other field. Thanks in advance, and I appreciate any guidance you can provide.