ainoy31 Posted May 4, 2009 Share Posted May 4, 2009 I have a form that allows someone to fill in data of a local jurisdiction(city or county) on a state. The first thing is that the state must be defined as a City or County first. So, I have a dynamic drop down menu that displays all the states on the US to choose from. Then the page reload with what state was selected and I check to to see if the state is defined as County or City. This all is working fine. My problem is on how to display an js alert popup message if the state's local jurisidiction has not been defined. Here is the code for the drop down menu: $sql = "SELECT DISTINCT(stateid) FROM counties"; $data = mysql_query($sql); ?> <div class="spacer"> <form name="localjuris" method="post" action="xxx.php"> <center><table class="tablesubmit" width="550" height="900"> <tr> <td>State</td> </tr> <tr> <td> <select name="state" onchange="reload();"> <? if(!empty($state)) { ?> <option value="<?=$state;?>"><?=$state;?></option> <?} else { ?> <option value=""></option> <? } while($row=mysql_fetch_array($data)) { extract($row); ?> <option value="<?=$stateid;?>"><?=$stateid;?></option> <?}?> </select> </td> </tr> Here is the JS for the reload(): function reload() { var data = document.localjuris.state.options[document.localjuris.state.options.selectedIndex].value; self.location='xxx.php?state=' + data; } I am trying to figure out a way validate that a state has a defined jurisdiction, if not, then popup an alert message right away on the drop down selection. I hope this is not confusing to follow. Much appreciation. AM Quote Link to comment https://forums.phpfreaks.com/topic/156820-solved-dynamic-drop-down-menu/ Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 Read rules #8 and #22 - http://www.phpfreaks.com/page/forum-rules Quote Link to comment https://forums.phpfreaks.com/topic/156820-solved-dynamic-drop-down-menu/#findComment-825962 Share on other sites More sharing options...
ainoy31 Posted May 4, 2009 Author Share Posted May 4, 2009 Hey Ken2k7 Good to be original with the name there. Do me a favor and don't post your stupid comments on my post. If I need your two cents, I will email you directly. Quote Link to comment https://forums.phpfreaks.com/topic/156820-solved-dynamic-drop-down-menu/#findComment-826001 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.