jQuery Mobile 2-page Base Fiddle
HTML
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css">
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<div id="groups">
<fieldset id="TV_fieldset" data-mini="true" data-role="controlgroup" data-type="horizontal">
<legend>Limit:</legend>
<input type="radio" name="Limit_Total" id="Limit_Total_1" value="1">
<label for="Limit_Total_1">One</label>
<input type="radio" name="Limit_Total" id="Limit_Total_2" value="2">
<label for="Limit_Total_2">Two</label>
<input type="radio" name="Limit_Total" id="Limit_Total_3" value="3">
<label for="Limit_Total_3">Three</label>
<input type="radio" name="Limit_Total" id="Limit_Total_4" value="4">
<label for="Limit_Total_4">Four</label>
<input type="radio" name="Limit_Total" id="Limit_Total_5" value="5">
<label for="Limit_Total_5">Five</label>
<input type="radio" name="Limit_Total" id="Limit_Total_6" value="6">
<label for="Limit_Total_6">Six</label>
</fieldset>
<fieldset id="Child_fieldset" data-mini="true" data-role="controlgroup" data-type="horizontal">
<legend>Child:</legend>
<input type="radio" name="Child_Total" id="Child_Total_0" value="0" checked>
<label for="Child_Total_0">None</label>
<input type="radio" name="Child_Total" id="Child_Total_1" value="1">
<label for="Child_Total_1">One</label>
</fieldset>
<fieldset id="Second_Child_fieldset" data-mini="true" data-role="controlgroup" data-type="horizontal">
<legend>Second Child:</legend>
<input type="radio" name="Second_Child_Total" id="Second_Child_Total_0" value="0" checked>
<label for="Second_Child_Total_0">None</label>
<input type="radio" name="Second_Child_Total" id="Second_Child_Total_1" value="1">
<label for="Second_Child_Total_1">One</label>
</fieldset>
<fieldset id="Third_Child_fieldset" data-mini="true"...
JavaScript
$('div#groups').on('change', 'input[name="Limit_Total"]', updateUI);
$('div#groups').on('change', 'input[name="Child_Total"]', updateUI);
$('div#groups').on('change', 'input[name="Second_Child_Total"]', updateUI);
$('div#groups').on('change', 'input[name="Third_Child_Total"]', updateUI);
$('div#groups').on('change', 'input[name="Fourth_Child_Total"]', updateUI);
$('div#groups').on('change', 'input[name="Fifth_Child_Total"]', updateUI);
function updateUI(element) {
var limit = parseInt($('input[name="Limit_Total"]:checked').val(), 10);
// Children
var childCount = parseInt($('input[name="Child_Total"]:checked').val(), 10);
var secondChildCount = parseInt($('input[name="Second_Child_Total"]:checked').val(), 10);
var thirdChildCount = parseInt($('input[name="Third_Child_Total"]:checked').val(), 10);
var fourthChildCount = parseInt($('input[name="Fourth_Child_Total"]:checked').val(), 10);
var fifthChildCount = parseInt($('input[name="Fifth_Child_Total"]:checked').val(), 10);
// Totals
var totalChildern = childCount + secondChildCount + thirdChildCount + fourthChildCount + fifthChildCount;
// // Enable the correct combination of children
$('input[name*="Child_Total"]').not(element).checkboxradio('disable').checkboxradio('refresh');
for (var i = 0; i <= 6; i++) {
if (i <= (limit - totalChildren)) {
$('input[id$="Child_Total_' + i + '"]').not(element).checkboxradio('enable').checkboxradio('refresh');
} else {
$('input[id$="Child_Total_' + i + '"]').not(element).attr('checked', false).checkboxradio('refresh');
}
}
}