|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi
I am building a web page which has two drop down menus one for country and one for region, The region box is filled with regions corresponding to the country currently selected in the country drop down. I am using PHP and MYSQL to dynamically generate the regions and countries. So on the intial load the counrty selected is England and has value of 1 in the database , thus it generates the regions which have counrty value 1. i need a script which can detect a change in the counrty drop down , pass the value of the drop down and reload the page using this value , for if Scotland was selected the page would reload with country value = 2 etc. i think i need a piece of javascript , can anyone help? Thanks in advance Waseem |
|
#2
|
|||
|
|||
|
You mean something like this?
http://www.wsabstract.com/script/cut183.shtml Spookster ------------------ Visit the WSAbstract Help Forum for your Javascript, DHTML, or General Web Design Questions |
|
#3
|
|||
|
|||
|
Thanks for the reply i got it to work by using the onChange function
|
|
#4
|
|||
|
|||
|
walshs,
I've been trying to accomplish the exact same thing (except not country/regions) with php and mysql. I used the onchange, which works great, and refreshed the page, but it doesn't work in netscape. It also was a pain to get the code working which kept the correct value in the first dropdown and recognized whether you were coming into the page for the first time or whether you had changed the first dropdown and were now refreshing the second one. Can you show me the code you used to get it to work? Here's my code that "almost" works. It started out simple, but with the problems, grew into frankenstein. function ProcSel(themfg) { SetCookie("cmfg",themfg.value); self.location.reload(); } function SetCookie (name,thevalue) { document.cookie = name + ' = ' + thevalue + ';'; } <?PHP $rslt = mysql_query("SELECT DISTINCT mfg FROM equipment WHERE type='COMPUTER'", $dbConnect); echo "<SELECT NAME='mfg' onChange='ProcSel(this)' SIZE='1'>n"; if ($cmfg=="") if(mysql_num_rows($rslt)) $cmfg=mysql_result($rslt,0,"mfg"); while ($row = mysql_fetch_array($rslt)) { echo "<OPTION VALUE='".$row['mfg']."'"; if ($cmfg == $row['mfg']) echo " SELECTED>".$row['mfg']."n"; else echo ">".$row['mfg']."n"; } echo "</SELECT>n"; ?> Choose Model:</TD> <?PHP $rslt = mysql_query("SELECT model,va,modelid FROM equipment WHERE mfg='$cmfg' AND type='COMPUTER'", $dbConnect); echo "<SELECT NAME='model' SIZE='1'>n"; while ($row = mysql_fetch_array($rslt)) { echo "<OPTION VALUE='".$row['modelid']."'>".$row['model']." (".$row['va']." VA)n"; } echo "</SELECT>n"; ?> ------------------ -Randy |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Drop Down Menu Refresh |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|