Hello Everyone,
Re post "Simple checkbox replacement"... Very nice indeed, well done Kawika.
Here is my first attempt at writing some simple generic utilities for
chechboxes, the first one makes a group of checkboxes operate like radio
buttons and the second is simply a check/uncheck all checkboxes in a
group (thanks to Mike Alsup for the inspiration here).
I would appreciate any improvements and suggestions.
I think it would be nice to have a collection of useful utilities like
these in the forms plugin or perhaps a form utilities plugin etc.
Keep up the great work everyone.
Rob
Code:
$.radioCheckboxGroup = function(element) {
var x= $('[EMAIL PROTECTED]' + element + ']');
x.click(function() {
x.each(function() {
this.checked = false;
});
this.checked = true;
});
}
$.selectDeselectAll = function(ctrl,element) {
$('[EMAIL PROTECTED]' + ctrl + ']').click(function() {
var x = this.checked;
$('[EMAIL PROTECTED]' + element + ']').each(function() {
this.checked = x;
});
});
}
Usage:
$(document).ready(function() {
$.radioCheckboxGroup('stuff');
$.selectDeselectAll('removeAll','remove[]');
});
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/