Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/156820-solved-dynamic-drop-down-menu/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.