2012-07-23 72 views
0

我已經嘗試過下面的代碼,以便將值傳遞給另一個PHP頁面,但我沒有得到任何東西。傳遞值到PHP文件

文件名:Send.html

<form id="form1" action="get.php" method="get"> 
<input name="search_name" type="text" id="search_name" size="20.5" height="45" border="#770074" > 
<select name="mydropdown" width="230" STYLE="width: 180px" size="0" "height: 200px"> 
<option value="All">All Categories</option> 
<option value="Childrens Clothing">Childrens Clothing</option> 
</select> 
<img src="../img/search.jpg" width="70" height="45" border="0" align="left" usemap="#Map"> 
</form> 

<map name="Map"> 
<area shape="poly" coords="5,35" href="#"> 
<area shape="rect" coords="-5,8,140,45" href="get.php"> 
</map> 

文件名:get.php

<?php 
$sname=$_GET['search_name']; 
$cname=$_GET['mydropdown']; 
echo $sname."<br>".$cname; 
?> 
+2

你如何提交表格? (似乎沒有提交按鈕。) – grammar31 2012-07-23 18:40:00

+1

單擊鏈接(即在圖像映射上)不會發布表單。 – mellamokb 2012-07-23 18:40:13

+1

您是否正在使用圖片地圖中的鏈接?這是行不通的。你需要一個正確的提交按鈕或者你需要使用JavaScript。 – JJJ 2012-07-23 18:40:21

回答

0
<img onclick="document.getElementById('form1').submit();" src="../img/search.jpg" width="70" height="45" border="0" align="left" usemap="#Map"> 
0

Send.html</form>前添加<input type="submit" value="Submit" />添加適當的提交按鈕。

編輯 如果您想使用的圖像,你可以這樣做:

<button type="submit"><img src="..." /></button> 
0
<area shape="rect" coords="-5,8,140,45" onclick="document.form1.submit();"> 

這是webarto的回答有點編輯,因爲我認爲你只想要一個特定的區域作爲您的提交按鈕上的圖像。