PDA

View Full Version : mysql ajax dynamic list to fill more than 1 textbox with a dif.value for each?


Jodarecode
10-26-2007, 07:06 PM
Ok, I have a database:
ie...
Id | cab | price | w1

1 | wall | $300 | $19

on my form I have three textboxes:
input1 is cab with autocomplete, input2 is price, & input3 is w1

The way I have it now works great, I type a few letters in input1, it pulls up a list, once cab is selected it populates input1 with cab and input2 with price.

I want to know once cab is selected, if it can populate input2 with price & input3 with w1 as well?

Im using the script from here:
http://www.dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-list

This is the php code for accessing the DB

<?

$conn = mysql_connect("localhost","x","x");
mysql_select_db("x",$conn);


if(isset($_GET['getCabinetsByLetters']) && isset($_GET['letters'])){
$letters = $_GET['letters'];
$letters = preg_replace("/[^a-z0-9 ]/si","",$letters);
$res = mysql_query("select * from cabinets where cab like '".$letters."%'") or die(mysql_error());
#echo "1###select * from cabinets where cab like '".$letters."%'|";

while($inf = mysql_fetch_assoc($res))

{
echo = $inf["price"]."###".$inf["cab"]."|";
}

}
?>

Any help, much appreciated!!

Inigoesdr
10-27-2007, 01:04 AM
Sure, just select the additional fields you need and pass them back to the script via the AJAX method you're already using.