做這個塊我覺得有一定是這樣選擇的填充一個更好的方式方法....更好的在PHP
<p>
<label for="industry" class="medium">Industry</label>
<select name="industry" >
<option value="" selected="<?php if($_POST['industry'] =="") { echo "selected";} ?>">-- Select Industry --</option>
<option value="Retail" selected="<?php if($_POST['industry'] =="Retail") { echo "selected";} ?>">Retail</option>
<option value="Restaurant" selected="<?php if($_POST['industry'] =="Restaurant") { echo "selected";} ?>">Restaurant</option>
<option value="Salon" selected="<?php if($_POST['industry'] =="Salon") { echo "selected";} ?>">Salon</option>
<option value="Pizza Delivery" selected="<?php if($_POST['industry'] =="Pizza Delivery") { echo "selected";} ?>">Pizza Delivery</option>
<option value="Grocery" selected="<?php if($_POST['industry'] =="Grocery") { echo "selected";} ?>">Grocery</option>
<option value="Quick Service" selected="<?php if($_POST['industry'] =="Quick Service") { echo "selected";} ?>">Quick Service</option>
<option value="Liquor Store" selected="<?php if($_POST['industry'] =="Liquor Store") { echo "selected";} ?>">Liquor Store</option>
<option value="Tobacco" selected="<?php if($_POST['industry'] =="Tobacco") { echo "selected";} ?>">Tobacco</option>
<option value="Video Store" selected="<?php if($_POST['industry'] =="Video Store") { echo "selected";} ?>">Video Store</option>
<option value="Other" selected="<?php if($_POST['industry'] =="Other") { echo "selected";} ?>">Other</option>
</select>
</p>
看看這個:http://stackoverflow.com/questions/5249904/how-to-populate-listbox-drpdown-box-select-box-from-php-array/5249998#5249998 – amosrivera 2011-03-10 20:56:22
我使用CodeIgniter。他們有一個form_helper將爲你做這個。 :-D – 2011-03-10 20:58:57