Thanks for your response ,

In my application i dont want default checked = checked ,


Then how i do Peter ,

Thanks

There are a few ways to do this.
You can select by class, in which case you give a group of checkboxes the
same class

$(function(){
// attach a click event to each checkbox whose class is 'onechecked'
$(':checkbox.onechecked').click(function(){
  // if the clicked checkbox is checked (no need to do anything if it is
being unchecked)
  if (this.checked) {
    // loop through all other checkboxes with the same class
    $(':checkbox.onechecked').each(function(){
      // uncheck all of them
      this.checked = false;
    });
    // re-check the one clicked
    this.checked = true;
  }
});
});

HTML:
<fieldset>
<input type="checkbox" checked="checked" name="cb1" class="onechecked" />
<input type="checkbox" name="cb2" class="onechecked" />
<input type="checkbox" name="cb3" class="onechecked" />
<input type="checkbox" name="cb4" class="onechecked" />
</fieldset>

you can also use the name attribute of the checkbox to group them - this
could work for multiple groups of checkboxes - this example assumes that
each group of checkboxes has the same name attribute, and those you want to
limit to one selection are prefixed 'limit'

$(function(){
// attach a click event to each checkbox whose name begins with 'limit'
$(':checkbox[name^=limit]').click(function(){
  // store the name of the checkbox which has been clicked
  var inputname = $(this).attr("name");
  // if the clicked checkbox is checked (no need to do anything if it is
being unchecked)
  if (this.checked) {
    // loop through all other checkboxes with the same name attribute as the
one clicked
    $(':checkbox[name='+inputname+']').each(function(){
      // uncheck all of them
      this.checked = false;
    });
    // re-check the one clicked
    this.checked = true;
  }
});
});

HTML:
<fieldset>
<input type="checkbox" checked="checked" name="limit1" />
<input type="checkbox" name="limit1" />
<input type="checkbox" name="limit1" />
<input type="checkbox" name="limit1" />
</fieldset>
<fieldset>
<input type="checkbox" checked="checked" name="limit2" />
<input type="checkbox" name="limit2" />
<input type="checkbox" name="limit2" />
<input type="checkbox" name="limit2" />
</fieldset>

There are other ways as well, but this should give you some idea about some
of the possibilities.

on 15/05/2009 15:48 elubin said::
> add a click handler to each checkbox (you could use a selector and
> loop through with $.each).  when clicked, the function could use the
> same selected and loop through again making sure the others are off.
>
> Eric
>
>
>
> On May 15, 10:38 am, bharani kumar <bharanikumariyer...@gmail.com>
> wrote:
>
>> Hi all
>>
>> Can u tell me , how to uncheck the check box , when i check another check
>> box,
>>
>> for example
>>
>> having 4 check boxes,
>>
>> be default check box is checked ,.
>>
>> when i check the check box 2 , then need to uncheck the checked one ,
>>
>> How to do this in jquery ,
>>
>> Thanks
>>
>> --
>> உங்கள் நண்பன்
>> பரணி  குமார்
>>
>> Regards
>> B.S.Bharanikumar
>>
>> POST YOUR OPINIONhttp://bharanikumariyerphp.site88.net/bharanikumar/
>>
>
>

-- 
உங்கள் நண்பன்
பரணி  குமார்

Regards
B.S.Bharanikumar

POST YOUR OPINION
http://bharanikumariyerphp.site88.net/bharanikumar/

Reply via email to