I had a problem setting up my styleclass in struts, here how I fixed it.
I hope the code come nicely in that theme.
In struts class is not recognized but styleClass is :
http://struts.apache.org/1.x/struts-taglib/tlddoc/html/checkbox.html
you can check the source the styleClass is generated class.
<script language=”JavaScript”>
$(function () {
$(‘#checkall’).toggle(
function() {
$(‘#resultTable .tf’).prop(‘checked’, true);
},
function() {
$(‘#resultTable .tf’).prop(‘checked’, false);
}
);
});
</script>
class=”tf” or styleClass if your using struts like me
but his work but only for a button, if checkall is the id of a checkbox with the class tf, it’s change all the checkbox except it’s self
then I tried that: (from : http://stackoverflow.com/questions/2228382/select-all-checkboxes-with-jquery)
$(‘#checkall’).change(function() {
var checkboxes = $(this).closest(‘form’).find(‘:checkbox’);
if($(this).is(‘:checked’)) {
checkboxes.attr(‘checked’, ‘checked’);
} else {
checkboxes.removeAttr(‘checked’);
}
Mix the 2 solutions together you get the working solution:
$(function () {
$(‘#checkall’).change(
function() {
if($(this).is(‘:checked’))
$(‘#resultTable .tf’).prop(‘checked’, true);
else
$(‘#resultTable .tf’).prop(‘checked’, false);
}
);
});
Hope it help !
Recent Comments