views:

119

answers:

1

Hi, I'm trying to create a simple search function where a user selects an option from a drop down and clicks on a map to see results for those 2 parameters

I have this php at the top of my doc:

<?php if ((isset($_POST["MM_search"])) && ($_POST["MM_search"] == "yes")){

 $lang = $_POST['lang'];
 $salerent = $_POST['salerent'];
 $zone = $_POST['zone'];

 $updateGoTo = '/'.$lang.'/'.$salerent.'/'.$zone.'/results.html';

  header("Location: $updateGoTo");


} ?>

then I have this javascript and form:

<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<select name="salerent" id="salerent">
<option value="forsale" selected="selected">For Sale</option>
<option value="forrent">For Rent</option>

</select>


<script type="text/javascript" language="javascript">

function submitMyForm(aForm, val)
{
 aForm.zone.value = val;
 aForm.submit()
}
</script>


<input type="hidden" name="lang" value="en" />
<p><img src="images/maps/island.gif" alt="Search" width="150" height="150" border="0" usemap="#Map" id="Image1" />
<map name="Map" id="Map">

<area shape="poly" coords="65,30,71,49,83,52,88,63,98,67,104,55,108,41,114,38,126,36,135,34,135,19,120,17,116,10,87,18" onclick="javascript:submitMyForm('document.form1','san-juan')" name="zone" id="zone" value="san-juan" alt="San Juan" onmouseover="MM_swapImage('Image1','','images/maps/juan.gif',1)" onmouseout="MM_swapImgRestore()" />

I get aForm.zone is undefined in in FireBug but suspect that isn't going to work like this anyway...can anyone please help?

Thanks

A: 

instead of assigning the value to the zone area, create an hidden form field, with a different name, that will hold that value for you.

In your javascript code:

function submitMyForm(aForm, val) {
 aForm.aHiddenZone.value = val;
 aForm.submit()
}

and later in your html form:

<input type="hidden" name="aHiddenZone" value="" />
Yoni
Hi, thanks for the reply that works!...I also had to remove the '' from 'document.form1' to : submitMyForm(document.form1,'san-juan')Thanks very much for your help.
Peter