Php ofvar nux=$('#unitcount').text()它只是varnux=$('#unitcount')然后在下面的比较中,它变为max.text() <select name="form[norequnit][]" id="norequn
ofPhp ofvar nux=$('#unitcount').text()它只是varnux=$('#unitcount')然后在下面的比较中,它变为max.text() <select name="form[norequnit][]" id="norequn,php,jquery,ajax,checkbox,Php,Jquery,Ajax,Checkbox,ofvar nux=$('#unitcount').text()它只是varnux=$('#unitcount')然后在下面的比较中,它变为max.text() <select name="form[norequnit][]" id="norequnit" class="rsform-select-box"> <option value="">...</option> <option value="1">1</option>
var nux=$('#unitcount').text()代码>它只是varnux=$('#unitcount')代码>然后在下面的比较中,它变为max.text()
<select name="form[norequnit][]" id="norequnit" class="rsform-select-box">
<option value="">...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<input name="chk" type="checkbox" class="bd-lable" value="9432"><label>01</label>
<input name="chk" type="checkbox" class="bd-lable" value="9432"><label>02</label>
<input name="chk" type="checkbox" class="bd-lable" value="9432"><label>03</label>
<input name="chk" type="checkbox" class="bd-lable" value="9432"><label>04</label>
<input name="chk" type="checkbox" class="bd-lable" value="9432"><label>05</label>
<input name="chk" type="checkbox" class="bd-lable" value="9432"><label>06</label>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#norequnit").on("change", function () {
$('#unitcount').html($(this).find('option:selected').text());
});
$( document ).ajaxComplete(function() {
$( ".log" ).text( "Triggered ajaxComplete handler." );
var nux = $('#unitcount').text();
$("input[name=chk]").change(function(){
var max= nux;
if( $("input[name=chk]:checked").length == max )
{
$("input[name=chk]").attr('disabled', 'disabled');
$("input[name=chk]:checked").removeAttr('disabled');
}
else{
$("input[name=chk]").removeAttr('disabled');
}
})
});
});
</script>
var nux; // 1. This will hold the value of nux for use in your script
$("#norequnit").on("change", function () {
nux = $(this).val(); // 1. Save the data, 2. Use using val()
$('#unitcount').html(nux); // 1. Use the data
});
// Assuming you've got your ajax call somewhere else, use the "success"
// handler instead of the "ajaxComplete" function
$.ajax({
url: yourUrl,
method: 'get',
data: {
param1: 'value1',
param2: 'value2', // etc
},
success: function(html) {
// Presumably this is the HTML for your checkboxes, so add them
// to the DOM
$('#norequnit').after(html);
// And the only thing that really should go here otherwise is
// your bit of debug logging
console.log("Triggered ajax success handler.");
}
});
console.log("Triggered ajaxComplete handler.");
$(document).on('change', 'input[name="chk"]', function() {
// Handler code here
});
jQuery(document).ready(function($) {
var nux;
$("#norequnit").on("change", function () {
nux = $(this).val();
$('#unitcount').html(nux);
});
$.ajax({
url: yourUrl,
method: 'get',
data: {
param1: 'value1',
param2: 'value2', // etc
},
success: function(html) {
$('#norequnit').after(html);
console.log("Triggered ajax success handler.");
}
});
$(document).on("change", 'input[name="chk"]', function() {
if ($('input[name="chk"]:checked').length == nux) {
$('input[name="chk"]').attr('disabled', 'disabled');
$('input[name="chk"]:checked').removeAttr('disabled');
// Alternatively you could do this:
$('input[name="chk"]').not(':checked').attr('disabled', true);
} else {
$("input[name=chk]").removeAttr('disabled');
}
});
});