...

View Full Version : Prepopulating two dropdownmenus from MySQL



Bigfinn
11-18-2010, 09:57 AM
Hi,

I'm using MySQL/PHP on the server side and I have a database with customers and customer specific products. I have a form where i would like to have a dropdown menu for both customers and products. Customer menu is prepopulated from DB and depending on that selection a new SQL-query will be made with that customers name and ultimately populate the next menu with specific customers products.

I am not familiar with JS so im kind of lost with it. I suppose i have to pass a queried customer array from PHP/HTML to JS and so forth. Or is JS a proper tool for this problem in the first place? Below is some simple code I have.



.
..
...
while ($row=mysql_fetch_array($result)) {
$customer=$row["customername"];
$options.="<OPTION VALUE=\"$customer\">".$customer.'</option>';
}

echo("<SELECT NAME=customername><OPTION VALUE=0><?=$options?>< /SELECT>");

...
..
.



Cheers,

Bigfinn

abduraooft
11-18-2010, 10:09 AM
Customer menu is prepopulated from DB and depending on that selection a new SQL-query will be made with that customers name and ultimately populate the next menu with specific customers products. Take a look at http://bonrouge.com/~chain_select_ajax



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum