3
我試圖創造一個用戶選擇從下拉選項下來並且點擊地圖上看到的結果對於那些2個參數JavaScript提交表單加上地圖區域的值?
我有這個PHP在我的文檔的頂部一個簡單的搜索功能:
<?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");
} ?>
然後我有這個JavaScript和形式:
<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()" />
我得到aForm.zone未定義在螢火但不會像上班懷疑這反正...任何人都可以請幫助?
感謝
您好,感謝的作品的答覆......我也不得不從刪除「」 'document.form1'爲:submitMyForm(document.form1,'san-juan') 非常感謝您的幫助。 – Peter 2010-01-28 14:50:17