Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 233909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:08:31+00:00 2026-05-11T20:08:31+00:00

I have group checkboxes and I like if this group have behaviour like radiobuttons

  • 0

I have group checkboxes and I like if this group have behaviour like radiobuttons with same name atribute.

Each checkbox has different name.

Only one can be chosen from checkboxes.

How I can do this?


Solution

Why I need this?
Because we need consistency webUI.
Please, this is not question about our application architecture. 🙂

HTML Sample

<div class="multiCheckBox">
 <span class="multiGroup">
  <div><input class="multiItem" value="111" name="list" type="checkbox" />111</div>
  <div><input class="multiItem" value="112" name="list" type="checkbox" />112</div>
  <div><input class="multiItem" value="113" name="list" type="checkbox" />113</div>
 </span>
 <span>
  <div><input class="multiItem" value="121" name="list" type="checkbox" />121</div>
  <div><input class="multiItem" value="122" name="list" type="checkbox" />122</div>
  <div><input class="multiItem" value="133" name="list" type="checkbox" />123</div>
 </span>
 <span>
  <div><input class="multiItem" value="131" name="list" type="checkbox" />131</div>
  <div><input class="multiItem" value="132" name="list" type="checkbox" />132</div>
  <div><input class="multiItem" value="133" name="list" type="checkbox" />133</div>
 </span>
</div>

JavaScript

var $groups = $("span.multiGroup", $that);
$groups.each(function() {
    var $group = $(this);
    var $checkboxes = $(":checkbox", $group);
    $checkboxes.click(function() {
        var $activeCheckbox = $(this);
        var state = $activeCheckbox.attr('checked');
        $checkboxes.attr('checked', false);
        $activeCheckbox.attr('checked', state);
    });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:08:31+00:00Added an answer on May 11, 2026 at 8:08 pm

    Here’s a hint: Use radio buttons. 😉

    I wouldn’t recommend doing this because it would be considered bad for usability and would certainly violate the principle of least surprise. Users have been conditioned to expect radios to accept 1 check and checkboxes to accept many. Don’t make your users think.

    If you have your reasons, though, here’s how to go about doing this with jQuery:

    <input type='checkbox' name='mygroup1' value='1' class='unique'>
    <input type='checkbox' name='mygroup2' value='2' class='unique'>
    <input type='checkbox' name='mygroup3' value='3' class='unique'>
    

    And the jQuery:

    var $unique = $('input.unique');
    $unique.click(function() {
        $unique.filter(':checked').not(this).removeAttr('checked');
    });
    

    And here’s a live sample.

    EDIT:

    As pointed out in the comments, this would allow the user to deselect all checkboxes even if they chose one initially, which isn’t exactly like radio buttons. If you want this, then the jQuery would look like this:

    var $unique = $('input.unique');
    $unique.click(function() {
        $unique.removeAttr('checked');
        $(this).attr('checked', true);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a group of checkboxes that all have the same name. They all
I am using jQuery 1.4.3. I have a group of checkboxes like this: <input
If I have groups of checkboxes like so: <input type=checkbox namecheckboxes1 value=#value1> <input type=checkbox
I have 4 group of checkboxes, in which i am grouping all this 4
I have a form that has a group of 13 checkboxes that together make
I have an application with a considerable amount of checkboxes. Each of them has
I have a group of checkboxes, one of them has a label of 'None'.
I have a group of checkboxes that I only want to allow a set
I have group of stored procedures with names like 'somename_%'. Are there any way
I have a group of buttons that should act like toggle buttons, but also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.