答案 0 :(得分:0)
/<form> etc...
<h2 >Choose your favourite colour</h2>
<select name="colour">
<option value="0" selected=<?php if($_POST['colour']){$state} else{ echo 'false'} ?> >Choose a colour:</option>
<option value="1">Beige</option>
<option value="2">Sand</option>
<option value="3">Tan</option>
</select>
//more form code
这里是php代码
if (isset($_POST['colour']) ) {
$colour = $_POST['colour'];
$state = 'false';
if($colour != 0) {
//data is all set, redirect
}else {
// no value has been set, redisplay form
$state = 'true';
}
}