请指导我在PHP变量的下拉列表中获取所选选项
Private Sub b_03_Click() ' Save
With Sheets("Data").ListObjects(1)
.ShowTotals = False
If c_01.ListCount = 0 Then .DataBodyRange.ClearContents
If c_01.ListCount > 0 Then .DataBodyRange.Resize(c_01.ListCount).Value = c_01.List
.ShowTotals = True
End With
Hide
End Sub
我需要在<div class="form-group">
<label class="control-label" for="input-order-type"><?php echo $entry_order_type; ?></label>
<select name="filter_order_type" id="input-order-type" class="form-control">
<option value=""></option>
<option value="<?php echo $filter_order_type; ?>">FB Orders</option>
<option value="<?php echo $filter_order_type; ?>">Direct Orders</option>
<option value="<?php echo $filter_order_type; ?>">Khathija's Orders</option>
<option value="<?php echo $filter_order_type; ?>">Ameer's Orders</option>
<option value="<?php echo $filter_order_type; ?>">Saheed's Orders</option>
<option value="<?php echo $filter_order_type; ?>">Nada's Orders</option>
<option value="<?php echo $filter_order_type; ?>">Henath's Orders</option>
<option value="<?php echo $filter_order_type; ?>">Noha's Orders</option>
</select>
<?php echo $filter_order_type; ?>
</div>
答案 0 :(得分:0)
在PHP中完成此操作的唯一方法是按用户提交表单,然后使用$_POST
或$_GET
变量读取提交的值。这个答案解释如下:https://stackoverflow.com/a/17139538/4264695
答案 1 :(得分:0)
您必须使用<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<map class="list-group" name="map">
<area id="section-1" class="list-group-item" shape="rect" coords="0,0,200,200" />
<area id="section-2" class="list-group-item" shape="rect" coords="242,194,393,288" />
<area id="section-2" class="list-group-item" shape="rect" coords="397,24,530,109" />
</map>
<img alt="Picture1" src="https://placehold.it/680x466" height="466" width="680" usemap="#map" data-cms="{'contentId':95875}" />
<div class="dropdowntest-content section-1">
<p>Hello world 1</p>
</div>
<div class="dropdowntest-content section-2">
<p>Hello world 2</p>
</div>
<div class="dropdowntest-content section-3">
<p>Hello world 3</p>
</div>
值检查默认值,如下所示。
例如,
php
您必须为所有<option value="your_default_value" <?php if(isset($filter_order_type)){ if($filter_order_type == 'your_default_value'){ echo 'selected'; } } ?> >FB Orders</option>
设置如下所示,并与您的option
值进行比较,并使用默认值进行检查。
答案 2 :(得分:0)
我使用表单提交用户选择的内容。当用户提交表单时,将发布所选值并将其带入变量$entry_order_type
。我想这就是你所期待的。希望能帮助到你。 :)
<?php
$entry_order_type ="Select order type from the list and press the submit button";
if(isset($_POST['filter_order_type'])){
$entry_order_type = $_POST['filter_order_type']; // Storing Selected Value In Variable
}
?>
<form action="#" method="post">
<div class="form-group">
<label class="control-label" for="input-order-type"><?php echo $entry_order_type; ?></label>
<select name="filter_order_type" id="input-order-type" class="form-control">
<option value=""></option>
<option value="FB Orders" <?php if($entry_order_type=="FB Orders"){echo "selected";} ?> >FB Orders</option>
<option value="Direct Orders" <?php if($entry_order_type=="Direct Orders"){echo "selected";} ?> >Direct Orders</option>
<option value="Khathija's Orders" <?php if($entry_order_type=="Khathija's Orders"){echo "selected";} ?> >Khathija's Orders</option>
<option value="Ameer's Orders" <?php if($entry_order_type=="Ameer's Orders"){echo "selected";} ?> >Ameer's Orders</option>
<option value="Saheed's Orders" <?php if($entry_order_type=="Saheed's Orders"){echo "selected";} ?> >Saheed's Orders</option>
<option value= "Nada's Orders" <?php if($entry_order_type=="Nada's Orders"){echo "selected";} ?> >Nada's Orders</option>
<option value="Henath's Orders" <?php if($entry_order_type=="Henath's Orders"){echo "selected";} ?> >Henath's Orders</option>
<option value="Noha's Orders" <?php if($entry_order_type=="Noha's Orders"){echo "selected";} ?> >Noha's Orders</option>
</select>
<input type="submit" name="submit" value="Get Selected Values" />
</div>
</form>