我想从下拉列表中回显选定的值。但这总是给我输出:默认
请检查我在做什么:
<div>
<select id="orderStatus" name="orderStatus">
<option value="0"></option>
<option value="Available">Available</option>
<option value="Arranging Product">Arranging Product</option>
<option value="Awaiting Fulfillment">Awaiting Fulfillment</option>
<option value="Awaiting Payment">Awaiting Payment</option>
<option value="Awaiting Pickup">Awaiting Pickup</option>
<option value="Awaiting Shipment">Awaiting Shipment</option>
</select>
// I think here is the problem when I click button it forgets selected index value
<a href="order.php" class="btn btn-large">Update</a>
</div>
Php代码:
<?php
$draft = isset($_GET['orderStatus'])? $_GET['orderStatus'] : 'DEFAULT';
echo $draft;
?>
当我单击更新按钮时,在输出中我总是得到默认值。我认为当我单击更新按钮时,它会忘记所选的索引值。
请提出我的错。
答案 0 :(得分:0)
添加到标签onmousedown事件:
2016-09-12 11:54:59.4919
2016-01-10 10:39:03.626985
2016-01-03 15:58:19.599016
2016-04-11 10:05:07.527829
2016-07-04 12:57:33.125333
2017-12-15 14:17:46.975731
2016-10-04 16:55:01.701048
2016-09-26 13:36:59.71145
2017-09-06 17:25:09.426963
2016-09-08 17:08:00.917743
这会将您的参数作为GET请求发送
答案 1 :(得分:0)
<div>
<form method="GET" action="order.php">
<select id="orderStatus" name="orderStatus">
<option value="0"></option>
<option value="Available">Available</option>
<option value="Arranging Product">Arranging Product</option>
<option value="Awaiting Fulfillment">Awaiting Fulfillment</option>
<option value="Awaiting Payment">Awaiting Payment</option>
<option value="Awaiting Pickup">Awaiting Pickup</option>
<option value="Awaiting Shipment">Awaiting Shipment</option>
</select>
<button type="submit" class="btn btn-large">Update</button>
</form>
</div>
答案 2 :(得分:0)
尝试一下,它的工作原理:
<?php
if(isset($_POST['submit'])){
$value = $_POST['orderStatus'];
echo $value;
}
?>
<form action="" method="post">
<select id="orderStatus" name="orderStatus">
<option value="0"></option>
<option value="Available">Available</option>
<option value="Arranging Product">Arranging Product</option>
<option value="Awaiting Fulfillment">Awaiting Fulfillment</option>
<option value="Awaiting Payment">Awaiting Payment</option>
<option value="Awaiting Pickup">Awaiting Pickup</option>
<option value="Awaiting Shipment">Awaiting Shipment</option>
</select>
<input type="submit" name="submit" value="Update" />
</form>