richcleverley
MIS
Hi all, I am using a javascript/php script to populate my select menus on a page. The php side of the script takes country information and when one is chosen it refreshes and populates a region select menu.
No this is fine when I only have one form on a page, but I need two. Depending on what I change, I either have the form not working at all, or when I change the second form the first one repopulates. Very annoying.
The javascript I am using is
The php for the first box is
followed by this for the form
How can I include a second form on the page that submits to a different file so that each form repopulates itseld seperately.
Hope this is in the right forum. I did think about posting in the php one but thought it was more of a javascript problem.
Thanks,
Richard
No this is fine when I only have one form on a page, but I need two. Depending on what I change, I either have the form not working at all, or when I change the second form the first one repopulates. Very annoying.
The javascript I am using is
Code:
function reload(form){
var val=form.country.options[form.country.options.selectedIndex].value;
self.location='index.php?country=' + val ;
}
The php for the first box is
Code:
///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT country_name,cid FROM country order by cid");
///////////// End of query for first list box////////////
/////// for second drop down list we will check if category is selected else we will display all the subcategory/////
if(isset($country) and strlen($country) > 0){
$quer=mysql_query("SELECT DISTINCT region_name,rid FROM region where cid=$country order by region_name");
}else{$quer=mysql_query("SELECT DISTINCT region_name FROM region order by region_name"); }
////////// end of query for second subcategory drop down list box ///////////////////////////
followed by this for the form
Code:
<form action="testform.php" method="post" name="proprent" id="proprent" onSubmit="YY_checkform('proprent','country','#q','1','Country Must be selected.','Bedrooms','#q','1','Number of Bedrooms must be selected');return document.MM_returnValue">
<label> <br>
<span class="formspacing">
<?
echo "<select name='country' onchange=\"reload(this.form)\" class=\"formelements\"><option value='' >Country?</option>";
while($noticia2 = mysql_fetch_array($quer2)) {
if($noticia2['cid']==@$country){echo "<option selected value='$noticia2[cid]'>$noticia2[country_name]</option>"."<BR>";}
else{echo "<option value='$noticia2[cid]'>$noticia2[country_name]</option>";}
}
echo "</select>";
?>
</span><br>
<br>
</label>
<label>
<?
echo "<select name='region' class=\"formelements\"><option value=''>Region?</option>";
while($noticia = mysql_fetch_array($quer)) {
echo "<option value='$noticia[rid]'>$noticia[region_name]</option>";
}
echo "</select>";
?><br><br>
<select name="Bedrooms" class="formelements" id="Bedrooms" >
<option>Bedrooms?</option>
<option value="5">5</option>
</select>
</label>
<br><br>
<div align="right">
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</div>
</form>
How can I include a second form on the page that submits to a different file so that each form repopulates itseld seperately.
Hope this is in the right forum. I did think about posting in the php one but thought it was more of a javascript problem.
Thanks,
Richard