[請益] 下拉式選單傳值問題

看板PHP作者 (乖乖)時間15年前 (2010/04/15 03:27), 編輯推噓0(005)
留言5則, 3人參與, 最新討論串1/1
想要做一個簡單的下拉式選單 可是傳過去目標頁面的值一直不會改變 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

04/15 08:28, , 1F
建議你先在前端頁面看一下原始碼option的資料對不對
04/15 08:28, 1F

04/15 08:29, , 2F
然後在目標頁var_dump($_POST)看看傳了哪些值,另外建議
04/15 08:29, 2F

04/15 08:30, , 3F
在建元件時,把id也加上去,例如id='xxx' name='xxx'>
04/15 08:30, 3F

04/15 13:21, , 4F
感謝~
04/15 13:21, 4F

04/17 11:24, , 5F
<option value='0'>
04/17 11:24, 5F
文章代碼(AID): #1BnXSTVb (PHP)
文章代碼(AID): #1BnXSTVb (PHP)