如下一段HTML表單,提交到recv.php顯示:
<form action="recv.php">
UserName:
<input type="text" name="username" /><br />
Sex:
<input type="radio" name="sex" value="male" checked="checked" />Male
<input type="radio" name="sex" value="female" />Female<br/>
Profession:
<select name="profession">
<option value="student">Student</option>
<option value="teacher">Teacher</option>
<option value="worker">Worker</option>
</select><br />
Favourite:
<input type="checkbox" name="favourite" value="basketball" checked="checked" />Basketball
<input type="checkbox" name="favourite" value="volleyball" />Volleyball
<input type="checkbox" name="favourite" value="football" />Football<br />
<input type="submit" value="Submit" />
</form>
recv.php代碼如下:
<?php
echo '<pre>';
print_r($_GET);
echo '</pre>';
?>
1、為何獲取到的多選項,如favourite,即使選了多個,在php裡也只能顯示一個,這是為什麼?如何才能全部顯示出來?
2、如果在select裡加入multiple="multiple",那麼這個下拉列表就不再在一行顯示,而是全部顯示出來,這是怎麼回事?我不就是想要變成多選而已嗎?如何處理呢?
謝謝!
1:http://www.jb51.net/article/23494.htm
2:指定size屬性顯示幾個項,但是size小於option數量需要滾動
<select name="profession" multiple size="2">
<option value="student">Student</option>
<option value="teacher">Teacher</option>
<option value="worker">Worker</option>
</select>