<div class="col-xs-4 pull-right">
<div class="input-group search-bar">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Filter by</span> <span class="caret"></span>
</button>
<?php $querySelectCategory = "SELECT * FROM auction_items_category";
$stmtSelectCategory = $conn->prepare($querySelectCategory);
$stmtSelectCategory->execute();
?>
<ul class="dropdown-menu" role="menu" id ="menu">
<?php while ($rowSelectCategory = $stmtSelectCategory->fetch()) {?>
<li id = "<?php echo $rowSelectCategory['categoryName'];?>"><a href="#<?php echo $rowSelectCategory['categoryName'];?>"><?php echo $rowSelectCategory['categoryName'];?></a></li>
<?php }?>
<li><a href="#all">Anything</a></li>
</ul>
</div>
<input type="text" id="searchTxt" class="form-control" placeholder="Search term...">
<span class="input-group-btn">
<button class="btn btn-default" id ="submitSearch" type="button"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
</div>
首先,我从数据库中获取所有值,然后显示到下拉菜单中,但是当用户单击搜索按钮时,如何获取下拉值? 以上是我的代码和结果。
答案 0 :(得分:2)
尝试:
$( "#submitSearch" ).click(function() {
var text = $('#search_concept').text();
});
答案 1 :(得分:0)
您需要将所有代码包装成标签,ACTION具有您的PHP代码的URL,所有输入都需要名称。
<form action="..." >
//your code
</form>
用php捕获值,或者你可以使用javascript和PHP的ajax。