Sam Collett wrote:
> On 05/10/06, Charles Peterson <[EMAIL PROTECTED]> wrote:
>   
>> Note sure where to post this so heres some code.
>> This allows you to have a set of "check all" check boxes that check
>> another set of check boxes.
>>
>> Example
>> $.checkallCheckboxClickEvent('.MyCheckAllClass','.CheckTheseClass');
>>
>>
>>
>>
>> /******************
>> // modified from check function() @
>> http://jquery.bassistance.de/jquery-getting-started.html
>> EXAMPLES
>> $("[EMAIL PROTECTED]'checkbox']").checkDynamic();
>> $("[EMAIL PROTECTED]'checkbox']").checkDynamic('on');
>> $("[EMAIL PROTECTED]'checkbox']").checkDynamic(true);
>> $("[EMAIL PROTECTED]'checkbox']").checkDynamic('off');
>> $("[EMAIL PROTECTED]'checkbox']").checkDynamic(false);
>> $("[EMAIL PROTECTED]'checkbox']").checkDynamic('toggle');
>> *******************/
>> /*
>>  * checks, unchecks or toggles a set of checkboxes.
>>  *
>>  * @name     $('?').checkDynamic
>>  * @param    mode  (true,'on',false,'off', or null) defaults to on if
>> null or other.
>>  * @author   Charles Peterson (http://www.artistandesigns.com)
>>  * @example  $(boxes_ele).checkDynamic(checked);
>>  *
>>  */
>> $.fn.checkDynamic = function(mode) {
>>     return this.each(function() {
>>         if($(this).is("[EMAIL PROTECTED]'checkbox']")){
>>             switch(mode) {
>>                 case false:
>>                 case 'off':
>>                     this.checked = false;
>>                     break;
>>                 case 'toggle':
>>                     this.checked = !this.checked;
>>                     break;
>>                 case true:
>>                 default://'on'
>>                     this.checked = true;
>>                     break;
>>             }
>>         }
>>     });
>> };
>>
>> /*
>>  * this sets a click event for "Check All" checkboxes.
>>  *
>>  * @name     $.checkallCheckboxClickEvent
>>  * @param    click_elem  Checkboxes that are for "Checking All"
>>  * @param    boxes_ele  Checkboxes to check when a Check All box is checked
>>  * @author   Charles Peterson (http://www.artistandesigns.com)
>>  * @example
>> $.checkallCheckboxClickEvent('.LISTTICKETselectedticketsCHECK','.LISTTICKETselectedtickets')
>>  *
>>  */
>> $.checkallCheckboxClickEvent = function(click_elem,boxes_ele){
>>     $(click_elem).click(function
>> (){$.checkallCheckbox(click_elem,boxes_ele,this.checked);});
>> };
>>
>> /*
>>  * this should be used with a click event function
>>  *
>>  * @name     $.checkallCheckbox
>>  * @param    click_elem  Checkboxes that are for "Checking All"
>>  * @param    boxes_ele  Checkboxes to check when a Check All box is checked
>>  * @param    checked  boolean, what to set the checkboxes to.
>>  * @author   Charles Peterson (http://www.artistandesigns.com)
>>  * @example  $(click_elem).click(function
>> (){$.checkallCheckbox(click_elem,boxes_ele,this.checked);});
>>  *
>>  */
>> $.checkallCheckbox = function(click_elem,boxes_ele,checked){
>>     // check all the boxes based on clicked element
>>     $(boxes_ele).checkDynamic(checked);
>>     // make sure all the CheckAll boxes are set the same also
>>     $(click_elem).checkDynamic(checked);
>> };
>>     
>
> I also did this a while ago (so you may have missed it):
> http://www.texotela.co.uk/code/jquery/checkboxes/
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>   

Ya, you inspired my improvement on the functions.
basically you are checking or unchecking ALL but "ignored" checkboxes on 
the page/form (useful, but not what I wanted)
I wanted to specify which ones to check,

$.checkallCheckboxClickEvent('.MyCheckAllClass','.CheckTheseClass');

and which ones to click to execute the checkall.
This way I have a table with checkboxes to select rows with a check all 
checkbox at the top and bottom of the table, the script checks/unchecks based 
on the state of the checkall checkboxes and also updates the checkall 
checkboxes to be in the same state.

basically I didn't want to specify which ones to ignore.



_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to