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 6075803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:32:07+00:00 2026-05-23T10:32:07+00:00

I made a small verification script which is supposed to act like this: I

  • 0

I made a small verification script which is supposed to act like this:
I have 4 checkboxes, one has a particular way of action, the id of this checkbox is chx0

  • If I checked the chx0 checkbox then it released all the others checked checkboxes

  • If I checked one of all the others checkboxes then it released the chx0 one

Here is my code:

<script type="text/javascript"> 
    
    $(document).ready(function() {
        $('#chx0').click(function() { // click on the chx0 checkbox
           
            if ($('#chx0').attr('checked')) {
                
                $('#chx1').attr('checked', false);
                $('#chx2').attr('checked', false);
                $('#chx3').attr('checked', false);
            }
        });
    
        $('#chx1').click(function() {// click on the chx1 checkbox
           
            if ($('#chx1').attr('checked')) {
                $('#chx0').attr('checked', false);
            }
        });
    
        $('#chx2').click(function() { // click on the chx2 checkbox
           
            if ($('#chx2').attr('checked')) {
                $('#chx0').attr('checked', false);
            }
        });
    
        $('#chx3').click(function() { // click on the chx3 checkbox
           
            if ($('#chx3').attr('checked')) {
                $('#chx0').attr('checked', false);
            }
        });

    });
    
</script> 

This code is working pretty well it just to get more good practice!

  • 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-23T10:32:08+00:00Added an answer on May 23, 2026 at 10:32 am

    I’d put a class on each checkbox

    <input type="checkbox" name="chx0" id="chx0" class="checkbox-group singleton">
    <label for="chx0">Check me out!</label>
    <input type="checkbox" name="chx1" id="chx1" class="checkbox-group">
    <label for="chx1">Check us out!</label>
    <input type="checkbox" name="chx2" id="chx2" class="checkbox-group">
    <label for="chx2">Check them out!</label>
    

    Then with your jQuery you can do

    $('input.checkbox-group').each( function() {
        $(this).click( function() {
            if ( $(this).hasClass('singleton') ) {
                $('input.checkbox-group:checked').removeAttr('checked');
            } else {
                $('input.checkbox-group.singleton').removeAttr('checked');
            }
        };   
    });
    

    Untested, but I think something like that should work. I can’t remember if it’s better to use the change event rather than click.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made a small program which has 2 buttons and each does certain thing.
I have made a small application in Java and I would like to make
Post-release, I have made one small change to one form in our development site
I made a small script which basically uses jQuery uplodify to upload files to
Ok i made a small script, which sets a $_SESSION[$_SERVER['REMOTE_ADDR']] the problem, it dont
I made this small Java program using eclipse IDE. I have set the workspace
I have made small app for Android mobile. In one situation I am not
I have made small jquery collapse/expand script http://jsfiddle.net/goldie/QFL49/ (please don't pay attenton to html/css
I have made a small software in qt and its only one executable and
i have made an small script to allow users to build they page or

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.