本文介绍了如何在引导程序中获取单选按钮组的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为表单中的单选按钮使用以下引导程序代码
I am using following code of bootstrap for my radio buttons inside a form
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" name="att" class="btn btn-primary active">Present</button>
<button type="button" name="att" class="btn btn-primary">Absent</button>
<button type="button" name="att" class="btn btn-primary">Leave</button>
</div>
您可以通过访问 http://getbootstrap.com/2.3来找到广播示例. 2/javascript.html#buttons
我将其用于员工出勤,因此有多个员工记录,并且将有一个数组.我已经尝试过问题获取Twitter引导程序收音机的值按钮. jQuery 但这只会返回我最后选择的值.
I am using this for employees attendance, so there are multiple records of employees and there will be a array.I have tried question Get the value of a twitter bootstrap radio button. JQuerybut this returns me only last selected value.
我该如何解决?
注意:我也尝试过输入标签而不是按钮,但是效果样式
Note: I have also tried input tag instead of button but that effect styling
推荐答案
我已经通过使用
<div id ="attend1" class="btn-group" data-toggle="buttons-radio">
<input type='hidden' name="attendy[]" value='default value'>
<button type="button" name="att" class="btn btn-primary active">Present</button>
<button type="button" name="att" class="btn btn-primary">Absent</button>
<button type="button" name="att" class="btn btn-primary">Leave</button>
</div>
和jQuery
$(document).ready(function (){
$('.btn').click(function() {
var parent = '#' + $(this).parent().attr('id');
$(parent).find('input').val($(this).text());
});
});
非常感谢大家
这篇关于如何在引导程序中获取单选按钮组的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!