I have the following code which is set on page load
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default active" for="hrb">
<input type="radio" id="hrb" name="period" value="hourly" /> Hourly
</label>
<label class="btn btn-default" for="drb">
<input type="radio" id="drb" name="period" value="daily" /> Daily
</label>
<label class="btn btn-default" for="wrb">
<input type="radio" id="wrb" name="period" value="weekly" /> Weekly
</label>
<label class="btn btn-default" for="mrb">
<input type="radio" id="mrb" name="period" value="monthly" /> Monthly
</label>
</div>
If I use jquery serialize to get the selected values it returns nothing
$(document).ready(function () {
var input = $(".btn-group").find('input');
console.log(input);
var data = input.serialize() ; //$( "form" ).serialize();
console.log(data);
});
I managed to do the following, unless someone has a better way of doing it?
var group_period = 'period=';
$('#group_period .active').each(function(){
group_period += $(this).attr('data-value');
});
var requiredrole = "requiredrole=" + $("requiredrole").val();
var data = requiredrole + "&" + group_period + "&" + $( "form" ).serialize();