我有以下代码,当我单击提交按钮时,我想获取引导下拉按钮上显示的文本的值,并且我还希望将 POST 发送到 codeigniter 控制器以对其执行某些操作. 我需要帮助。
<form method="post" action="#" id="user-order-form">
<div class="users-order col-md-5">
<label class=""> <strong>ORDER BY </strong></label>
<div class="dropdown form-control" style="padding:0px; margin-left: 20px; margin-right:10px">
<button class="btn btn-default dropdown-toggle form-control" type="button" id="user-order-dropdown" name="user-order-dropdown" data-toggle="dropdown">
Surname
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelled-by="user-order-dropdown" id="capton">
<li><a href="#">Surname </a> </li>
<li><a href="#">First Name </a> </li>
<li><a href="#">Company Name </a> </li>
</ul>
</div>
<label class="radio-inline"><input type="radio" name="order-radio" checked>ASC</label>
<label class="radio-inline"><input type="radio" name="order-radio">DESC</label>
<button type="submit" class="btn" name="order-submit-btn" id="order-submit-btn">Order</button>
</div>
</form>
这是显示所选下拉项的 jquery 代码:
$('.dropdown').each(function (key, dropdown) {
var $dropdown = $(dropdown);
$dropdown.find('.dropdown-menu a').on('click', function () {
$dropdown.find('button').text($(this).text()).append(' <span class="caret"></span>');
});
});
慕妹3242003