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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:46:44+00:00 2026-05-15T20:46:44+00:00

Here is my setup: If radiobutton1 is already checked when the page loads (it

  • 0

Here is my setup: If radiobutton1 is already checked when the page loads (it has checked="checked" in view source) and I try to uncheck it after selecting radiobutton2, the checked attribute on radiobutton1 is not getting removed after selecting radiobutton2:

if($('#' + radiobutton1_ID).is(':checked'))
    UncheckRadioButton('#' + radiobutton2_ID);

// Utility function to clear a radiobutton's "checked" attribute
function UncheckRadioButton(radiobuttonID) {
    radiobuttonID.removeAttr("checked"); 
}

After selecting radiobutton2 and doing a “View Source” I see no checked="checked" on radiobutton2 (even though the page shows this button as checked), and for radiobutton1 it still shows checked="checked". Why is that? It should be the other way around.


UPDATE

Here is some more of my code. I know that the if statement portions are getting hit so that’s not the issue, and I know the radio button IDs (ccRadioBtn, checkRadioBtn and paypalRadioButton) I am using are correct:

    var ccRadioBtn = ccRadioButton; // credit card radio button ID
    var paypalRadioButton = payPalRadioClientID;

    // ...

    if (paypalIsSelected()) {
        UncheckRadioButton(checkRadioBtn);
        UncheckRadioButton(ccRadioBtn);

        // ...
    } else {
        // force a clear on any previously selected payment options
        CheckRadioButton(ccRadioBtn); // default to credit card radio button
        UncheckRadioButton(paypalRadioButton);
        UncheckRadioButton(checkRadioBtn);

        // ...
    }
}

function UncheckRadioButton(radiobuttonID) {
    $('#' + radiobuttonID).removeAttr("checked"); 
}

function CheckRadioButton(radiobuttonID) {
    $('#' + radiobuttonID).attr('checked', true);
}

The problem is: If one radio button defaults to checked="checked" and I click another radio button, the first radio button’s checked attribute should be removed but it’s not. And the second radio button that has been selected has no checked="checked" as it should. I can see this when I view the page source. I am not sure why that is not working.

  • 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-15T20:46:44+00:00Added an answer on May 15, 2026 at 8:46 pm

    You’re passing a string here:

    UncheckRadioButton('#' + radiobutton_2_ID);
    

    But trying to use it as a jQuery object here:

    radiobuttonID.removeAttr("checked");
    //which is actually doing this:
    "#something".removeAttr("checked"); //.removeAttr() is not a function for string
    

    You need to wrap it to use it as a selector, like this:

    $(radiobuttonID).removeAttr("checked");
    

    As for the view source…it depends in the browser, IE for example will show the original source of the page, not the state you’re currently viewing.

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

Sidebar

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.