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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:28:14+00:00 2026-05-17T20:28:14+00:00

So this is the dumbest thing I’ve struggled with in awhile. I cannot get

  • 0

So this is the dumbest thing I’ve struggled with in awhile. I cannot get the state of a simple radio button set to toggle something on the page.

<label for="completeSw"><span>Completed?</span></label>
<input type="radio" id="completeSw" name="completeSw" value="1"/>Yes
<input type="radio" id="completeSw" name="completeSw" value="0" checked="checked"/>No<br/>

So you can see here an extremely simple yes/no radio button set to toggle an action. It needs to serve two purposes: to flag a yes/no value (1/0) in the POST data, and ideally trigger an action on the page using JS/jQuery. I’m having trouble with the latter.

The default state is “No”; if I click “Yes” I can retrieve an onchange or onclick event state and make something happen. However, this is a one-way switch; I cannot retrieve a state going back to the “No” selector once I’ve gone to “Yes”. What I need to be able to do is show / hide an element on the page depending on what choice they’ve made in this radio set. If I click “Yes”, I can trigger the action and see the page change. Once I click “No”, however, it acts as if there was no state change and I cannot perform an action i.e. hide the element again.

I’ve tried variations on retrieving the “checked” state, the radio pair value, etc, e.g.

$("#completeSw").change(function(e){
    alert( $(this).attr("checked") ); // only triggers when "Yes" is selected
});

Perhaps I should not be using a yes/no radio pair, but instead be using a single checkbox? Seems more user-friendly and elegant this way (radio buttons) to me.

  • 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-17T20:28:14+00:00Added an answer on May 17, 2026 at 8:28 pm

    IDs must be unique, so it will only ever find the first one on your page. Use a class instead.

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

Sidebar

Related Questions

Ok this is might be the dumbest question ever.. but i cannot for the
This is the dumbest little problem I am having and I CANNOT find the
Okay - this is the dumbest glitch I have seen in a while: <!DOCTYPE
This could quite possibly be the dumbest question ever asked. Our client wants us
This should be a simple one: I have an observableArray object called To in
I'm trying to build a simple application, with the finished program looking like this
This may or may not be the dumbest question ever. I'm using Restlet. When
This could turn out to be the dumbest question ever. I want to track
This has been asked several times, i know, but help me understand something. You
This may seems the most dumbest question ever on stackoverflow but I am just

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.