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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:11:38+00:00 2026-06-13T18:11:38+00:00

I need to set a radio button (‘no_subscribe’) to true when all the elements,

  • 0

I need to set a radio button (‘no_subscribe’) to true when all the elements, ‘checkbox’ are unchecked. This should happen after unchecking all these checkboxes.
Forgive me if this has been asked elsewhere. I am new to javascript and programming in general, so any help is greatly appreciated! I have been able to make the ‘subscribe’ button do what I want, but I can’t figure out the opposite scenario. These are inside a form called ‘mailer’. I recently deleted the attempts I have made. They were not working, so I am sorry there is no code to troubleshoot.

<fieldset>
Subscribe to our Mailing List?
        <input type = "radio" name = "yes" id = "subscribe" onclick = "subscribe_to_all();" value = "yes" />Yes
        <input type = "radio" name = "no" id = "no_subscribe" onclick = "subscribe_to_none();" value = "no" />No
</fieldset>

<fieldset name = "subscribe">
<legend>Mailing List Subscriptions</legend>
    <input type="checkbox" id = "c1" name="subscriptions" onclick = "radio_yes();"  value="CorporateEmails"/>
    Corporate Press Release Emails<br />
    <input type="checkbox" id = "c2" name="subscriptions" onclick = "radio_yes();"  value="SoftwareAdvertising"/>
    Upgrade Software Advertising List<br />
    <input type="checkbox" id = "c3" name="subscriptions" onclick = "radio_yes();"  value="PostBuyoutSpammers"/>
    List given to spammers after buyout<br />
    <input type="checkbox" id = "c4" name="subscriptions" onclick = "radio_yes();"  value="NonCynical"/>
    The only non-cynical list<br />
    <input type="checkbox" id = "c5" name="subscriptions" onclick = "radio_yes();"  value="SelltoSpammers"/>
    List to sell to spammers<br />
    <input type="checkbox" id = "c6" name="subscriptions" onclick = "radio_yes();"  value="SpamList"/>
    Spam List<br />

External javascript file:

function subscribe_to_all() {
    for (i = 0; i < document.mailer.subscriptions.length; i++) {
        document.mailer.subscriptions[i].checked = true;
    }
}

function subscribe_to_none() {
    for (i = 0; i < document.mailer.subscriptions.length; i++) {
        document.mailer.subscriptions[i].checked = false;
    }
}

function radio_yes() {
    document.getElementById("subscribe").checked = true;
}​
  • 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-13T18:11:39+00:00Added an answer on June 13, 2026 at 6:11 pm

    I’ve used a new function. It is not optimized . I’ve used a new function. There you can fetchthe checkbox status in a loop. But my code works. Just copy and paste and see the changes

        <script type="text/javascript">
    function subscribe_to_all() {
    
    for (i=0;i<document.mailer.subscriptions.length;i++){
    
    document.mailer.subscriptions[i].checked = true;
    
    }
    }
    
    function subscribe_to_none() {
    
    for (i=0;i<document.mailer.subscriptions.length;i++){
    
    document.mailer.subscriptions[i].checked = false;
    
    }
    }
    function radio_yes() {
    
    document.getElementById("subscribe").checked = true;
    
    }
    function radio_uncheck()
    {
    
    
            c1=document.getElementById("c1").checked;
            c2=document.getElementById("c2").checked;
            c3=document.getElementById("c3").checked;
            c4=document.getElementById("c4").checked;
            c5=document.getElementById("c5").checked;
            c6=document.getElementById("c6").checked;
            console.log(c1);
            if(c1==false && c2==false && c3==false && c4==false && c5==false && c6==false)
            {document.getElementById("subscribe").checked=false;}
    
        //document.getElementById("subscribe").checked=false;
    } 
    </script>
    
    <fieldset>
    Subscribe to our Mailing List?
            <input type = "radio" name = "yes" id = "subscribe" onclick = "subscribe_to_all();" value = "yes" />Yes
            <input type = "radio" name = "no" id = "no_subscribe" onclick = "subscribe_to_none();" value = "no" />No
    </fieldset>
    
    <fieldset name = "subscribe">
    <legend>Mailing List Subscriptions</legend>
        <input type="checkbox" id = "c1" name="subscriptions" onclick = "radio_yes();radio_uncheck();"  value="CorporateEmails"/>
        Corporate Press Release Emails<br />
        <input type="checkbox" id = "c2" name="subscriptions" onclick = "radio_yes();radio_uncheck();"  value="SoftwareAdvertising"/>
        Upgrade Software Advertising List<br />
        <input type="checkbox" id = "c3" name="subscriptions" onclick = "radio_yes();radio_uncheck();"  value="PostBuyoutSpammers"/>
        List given to spammers after buyout<br />
        <input type="checkbox" id = "c4" name="subscriptions" onclick = "radio_yes();radio_uncheck();"  value="NonCynical"/>
        The only non-cynical list<br />
        <input type="checkbox" id = "c5" name="subscriptions" onclick = "radio_yes();radio_uncheck();"  value="SelltoSpammers"/>
        List to sell to spammers<br />
        <input type="checkbox" id = "c6" name="subscriptions" onclick = "radio_yes();radio_uncheck();"  value="SpamList"/>
        Spam List<br />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to set 's:textarea' value which is selected in 's:radio' button. I am
I have a set of dijit.form.RadioButton elements. I need to be this set as
I need to set default value for radio button on load of document. I
How to set radio option checked onload with jQuery? Need to check if no
Need to set some attributes of button. For example Checked. I guess it is
I use h:selectOneRadio tag. I need to set the cursor focus to first radio
I have a set of radio buttons where when I click a radio button,
I'm using jQuery validation to validate a form with a radio button set on
So if this qstring var is set then i need to check a certain
I am trying to set a radio button. I want set it by using

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.