...

View Full Version : loading <select> options based on previous <select> choice



heaps21
07-15-2004, 09:13 PM
--------------------------------------------------------------------------------

Hi, I am quite rusty with javascript as I dont use it that often so i need a little guidance!!

I need to load the contents of a drop down menu but the contents are to be dependant on the selection of a previous drop down menu. It is of the form country-region-town. The values are stored in a database each with associated id's and foreign keys but i thought it was best to retrieve all items and then use javascript to load the appropriate contents, its just that I dont know how!!

I thought i'd ask as i imagine its something that developers come across every now and then. If ive got the wrong end of the stick and it is a php question let me know and I will post tin the other forum.

Thanks.

Vincent Puglia
07-15-2004, 09:22 PM
Hi,

see the cascading selects scripts/explanations at : http://members.aol.com/grassblad

also, dynamicdrive has one or two scripts w/o explanation

Vinny

heaps21
07-15-2004, 11:15 PM
thanks, thats a big help but im retrieving all my data from a mysql database and hence my arrays will be php arrays rather than javascript arrays, im a bit stuck on how to approach this!

Vincent Puglia
07-15-2004, 11:20 PM
<?
$connect = odbc_connect($db, $user, $pass) or die ($error);
$query = "SELECT * FROM TABLE";
$result = odbc_exec($connect, $query);

while(odbc_fetch_row($result))
$arrDef[] = '"'.$result.'"';

odbc_close($connect);

$strJsArr = implode(',', $arrDef);

echo 'var arr = ['.$strJsArr."]\n";
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum