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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:45:31+00:00 2026-06-06T22:45:31+00:00

I’m a little new to javascript. I have a bunch of checkboxes for an

  • 0

I’m a little new to javascript. I have a bunch of checkboxes for an html form. The checkboxes are dynamically generated from a python script. The last checkbox I have is entitled “N/A”, I want to make it so that if any of the other checkboxes are checked, the “N/A” checkbox automatically disappears. If the N/A checkbox is checked, the others disappear. And of course, if I uncheck the boxes, the opposite should occur. I know that i need to assign the different input fields different id’s so javascript can identify them, but I’m not sure how to write the javascript to make the actual disappearing action to occur.
Thank you.

edit;; Some dynamic python code:

print "<blockquote><strong>Labels:</strong><br/>"
for elem in output_list:
    if elem not in non_delete_list:
        print "<input type=\"checkbox\" name=\"remove_cd\" value=\"" + elem + "\" />" + elem + "<br/>"
print "<input type=\"checkbox\" name=\"remove_cd\" value=\"r_on\" />N/A:"
print_reason_list()
print "<font color=\"#cc0000\">Reason Required</font><hr/>"

So basically, anything with the value=elem part is dynamic, the final checkbox is N/A (value=”r_on”).

edit 2:

So I’m able to get the boxes to disappear thanks to @Ankit (using document….style.display= “none”). The issue I’m having is that once a box is checked, respective id becomes PERMANENTLY hidden. In order to fix this, I made a hide and unhide function and my onclick looks like:

"onclick=if(this.checked){hide("NA")}else{unhide("NA")}" 

And that allows me to uncheck the boxes and cause the respective tags to reappear. I’m running into a new issue however. With the checkboxes of value elem. If I check two boxes, and then uncheck one of the boxes, the “NA” appears again. I want it to remain hidden as long as there is an “elem” box that is checked. Basically, I need to rescan all the checkboxes to see their current states (I think). How can I do this?

  • 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-06-06T22:45:33+00:00Added an answer on June 6, 2026 at 10:45 pm

    You can enable/disable an html element through javascript with:

    document.getElementById('<the id of your checkbox here>').disabled = true;
    

    For your case just put a div tag around the dynamic check boxes and add/remove that div based on your need.

    Example:-

    print "<blockquote><strong>Labels:</strong><br/>"
    
    for elem in output_list:
        if elem not in non_delete_list:
            print "<div id=\"listBox\" >"
            print "<input type=\"checkbox\" name=\"remove_cd\" value=\"" + elem + "\" onclick=\"if(this.checked){myFunction("upperChkBoxes")}\" />" + elem + "<br/>"
            print "</div>"
    print "<input type=\"checkbox\" name=\"remove_cd\" value=\"r_on\"  onclick=\"if(this.checked){myFunction("NA")}\"  />N/A:"
    print_reason_list()
    print "<font color=\"#cc0000\">Reason Required</font><hr/>"
    
    
    function myFunction(par){
    // put your logic of add/remove here based on par value as "upperChkBoxes" or "NA"
    }
    

    Hope that helps.

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have a view passing on information from a database: def serve_article(request, id): served_article

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.