dongwei9365
2016-01-20 16:27
浏览 30

获取ul下拉值

<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>

Result

First i get all the value from database and then display into dropdown menu,but how can i get the dropdown value when the user click the search button? Above is my code and result.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongxingdu9594 2016-01-20 16:33
    已采纳

    Try:

    $( "#submitSearch" ).click(function() {
      var text = $('#search_concept').text();
    });
    
    点赞 打赏 评论
  • duanbage2161 2016-01-20 16:46

    You need wrap all your code into a labels, ACTION has the url of your PHP code will, all your inputs need a name.

    <form action="..." >
        //your code
    </form>
    

    catch the values with php, or you can use ajax with javascript and PHP.

    点赞 打赏 评论

相关推荐 更多相似问题