*/ /*Creates two form fields based on data from a database */ /*Writes javascript that update field 2 based on field 1 */ /***************************************************************/ /* To simulate database connectivity, I'll fill some arrays */ $store_id = array("1","3","4","5","6"); $store_state = array("California","California","California","Nevada","Utah"); $store_city = array("Los Angeles", "San Francisco", "Walnut Creek", "Las Vegas", "Salt Lake City"); $numStores = 5; $distinct_states = array("California","Nevada","Utah"); /* create the javascript function the updates the city list */ echo "\n\n"; echo "
"; echo "\n"; /* Now we need to know how many cities are listed for the state with the most stores */ /* select count(*) as items from store group by State order by items desc */ $MaxItems = 3; echo "

\n"; echo "
"; echo "\n"; ?>

Check out www.RestorationHardware.com to see this code used to take to a real database.