作者willy7954 (乖乖)
看板PHP
標題[請益] 下拉式選單傳值問題
時間Thu Apr 15 03:27:23 2010
想要做一個簡單的下拉式選單
可是傳過去目標頁面的值一直不會改變
echo "<form action='AdmModifyRightCheck.php' method='post'>";
echo "<table width='200' border='1' cellspaning='5' ><caption>Account
List</caption>";
echo "<td>Account</td><td align='center'>Change right</td><tr>";
while($row=mysql_fetch_array($result)){
echo "<td>$row[account]</td><td>";
echo "<input type='radio' name='account' value='$row[account]'> "; // radio
echo "<select name='userType'>";
if($row[type]==0){ echo "<option value=0 > student </option>"; }
else if($row[type]==1){ echo "<option value=1 > professor </option>"; }
echo "<option value=2 > admin </option>";
echo "</select>";
(若選擇 student 傳 0 )
(若選擇 professor 傳 1 )
(若選擇 admin 傳 2 )
echo "</td><tr>";
}
echo "</table><input type='submit' value='Change' ></form>";
可是我在 AdmModifyRightCheck.php 裡 echo "$_POST[userType]"
發現它的值不管如何必定為 1 ...為什麼會這樣~"~?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.249.60
→ marcoyan:建議你先在前端頁面看一下原始碼option的資料對不對 04/15 08:28
→ marcoyan:然後在目標頁var_dump($_POST)看看傳了哪些值,另外建議 04/15 08:29
→ marcoyan:在建元件時,把id也加上去,例如id='xxx' name='xxx'> 04/15 08:30
→ willy7954:感謝~ 04/15 13:21
→ manincloud:<option value='0'> 04/17 11:24