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

  • Home
  • SEARCH
  • 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 6867513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:19:08+00:00 2026-05-27T03:19:08+00:00

i am having n number check box, if i checked one check box it

  • 0

i am having n number check box, if i checked one check box it has to select all the similar values of the check box and the other check box should be disable.

can any one help me to solve the issue

i am having a java script for select similar values selection

<script type='text/javascript'>
(function()
{
 var allInps = document.getElementsByTagName('input'), allCb = [];

 for( var i in allInps )
  if( allInps[ i ].type === 'checkbox' )
  {
   allCb.push( allInps[ i ] );   
   allInps[ i ].onclick = likeMe;
  }

 function likeMe()
 {
  for( var i in allCb )
   if( allCb[ i ] !== this && allCb[ i ].value === this.value )
    allCb[ i ].checked = this.checked;  
 }  

})();
</script>

please Help!

  • 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-27T03:19:08+00:00Added an answer on May 27, 2026 at 3:19 am

    These lines aren’t needed:
    (function()
    {
    and this line:
    })();

    To disable a checkbox, checkbox.disabled = true; (where checkbox is the element you want to disable)

    In your likeMe function, add an else statement that disables the checkbox if they aren’t similar.

    I think that should work. here is how your code should be like:

    <script type='text/javascript'>
    (function()
    {
     var allInps = document.getElementsByTagName('input'), allCb = [];
    
     for( var i in allInps )
      if( allInps[ i ].type === 'checkbox' )
      {
       allCb.push( allInps[ i ] );   
       allInps[ i ].onclick = likeMe;
      }
    
     function likeMe()
     {
      for(var i in allCb )
       if( allCb[ i ] !== this && allCb[ i ].id === this.id )
        allCb[ i ].checked = this.checked;
        else if (allCb[ i ].checked !== this.checked && allCb[ i ].id !== this.id )
        { 
         allCb[ i ].setAttribute('disabled',true);
       } 
       else { 
         allCb[ i ].removeAttribute('disabled');
       }
     }
    
    })();
    

    I think it will solve it.

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

Sidebar

Related Questions

i am having week number and day of that week then how can i
I am having trouble with a template that has to check 3 different nodes
I'm having some checkboxes, where all have different values but all numbers. I want
I am having number of images with in my application. ( images more than
Am having a number of problems implementing the code from the Washington Post site
I am having a number of panels in my page in which I am
I am trying to understand if having different number of columns for different rows
We're having a significant number of problems creating a bulk upload function for our
Macs are renowned (or bemoaned) for having an extensive number of shortcuts. However, OS
We're having problem with a huge number of legacy stored procedures at work. Do

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.