有两个下拉框,通过(分区或名称)和搜索选项选择框进行搜索。所以我想根据下拉搜索的输入值来改变选择选项。根据我的代码,所有名称和分区搜索选项都不分开。
<table>
<tr>
<td style="width:auto>
<div class="form-group"><?php
<select name='by_type' value='' id='form-field-select-3' class='form-control search-select' data-placeholder='By' required><option></option>
<option value="division">Division</option>
<option value="name">Name</option>
</select>
</td><td></td>
<td style="width:auto>
<div class="form-group"><?php
$query1 = "SELECT emp_id, name FROM employee WHERE user_status='active' ORDER BY name ASC";
$result1 = mysql_query ($query1);
echo "<select name='emp_id' value='' id='form-field-select-3' class='form-control search-select' data-placeholder='Search Here' required> <option></option>";
while($r = mysql_fetch_array($result1)) {
echo "<option value=".$r['emp_id'].">".$r['name']."</option>";
}?>
<option value="Software Division">Software Division</option>
<option value="Financial Division">Financial Division</option>
<option value="Technical Division">Technical Division</option>
<option value="Research Division">Research Division</option>
<option value="Operation Division">Operation Division</option>
</td>
<td style="width:auto"><br>
<input type="submit" class="btn btn-purple" value="Search" name="click" style="height: 30px">
</td></tr></div></table>
请帮助我!
答案 0 :(得分:1)
您需要使用ajax来执行此操作。首先,显示部门下降&amp;使用带有onchange事件的js方法&amp;使用该下拉选项值调用ajax方法。然后将成功数据显示为第二次下拉。
喜欢这个 -
<script>
function select_division(){
$.ajax({
});
}
</script>
然后调用这样的ajax方法 -
standard
答案 1 :(得分:1)
使用ajax JQuery更改代码。
$.ajax({
url: "data.php",//file wich has query select to db table
data: {search:searching},//describe your data here
dataType: 'json',// type of data that will you get (JSON/HTML).
type: 'POST',//sending type (POST/GET)
success: function(data) {
//do change the select option
}
});