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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:37:17+00:00 2026-06-15T15:37:17+00:00

I am trying to make something which shows one of two divs based on

  • 0

I am trying to make something which shows one of two divs based on the selection of a radio button. In terms of radio buttons I have this code:

<input type="radio" name="radio-269" value="Purchase Only" />
<input type="radio" name="radio-269" value="Sale Only" />
<input type="radio" name="radio-269" value="Purchase and Sale" />

Then my DIV:

<div id="purchaseandsale" class="hidden" style="padding-top:10px; padding-bottom:10px; background-color: grey;">
Purchase and Sale
</div>

<div id="purchaseorsale" class="hidden" style="padding-top:10px; padding-bottom:10px; background-color: grey;">
Purchase or Sale
</div>

My Javascript:

<script>
$("select[name='radio-269']").change(function() {
    if ($(this).val() == "Purchase and Sale") {
       $('#added_fields').removeClass("hidden");
    }
    else {
        $('#added_fields').addClass("hidden");
    }
});
</script>

Firstly, it doesn’t work and doesnt give me an errors in console. How can I also get it show me the purcahseorsale div if “purchase” or “sale” radio button is shown?

  • 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-15T15:37:18+00:00Added an answer on June 15, 2026 at 3:37 pm

    You should be referring to input[name='radio-269'] instead of input[select='radio-269'].

    Also, your ID selectors don’t match those of the actual DOM.

    The JavaScript should be:

    $("input[name='radio-269']").change(function() {
        if ($(this).val() == "Purchase and Sale") {
           $('#purchaseandsale').removeClass("hidden");
        }
        else {
            $('#purchaseandsale').addClass("hidden");
        }
        if ($(this).val() == "Purchase Only" || $(this).val() == "Sale Only") {
           $('#purchaseorsale').removeClass("hidden");
        }
        else {
            $('#purchaseorsale').addClass("hidden");
        }
    });
    

    Check this JS Fiddle: http://jsfiddle.net/MrXenotype/ZpP7f/

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

Sidebar

Related Questions

I'm new to C++ and trying to make two simple functions, but something goes
I am trying to make a bar chart using tables, which I have almost
I have a ScrollView which has two hidden images, one at the top and
Im trying to make something similar to twitpic.com's email submission feature. Their address schema
Ok I am trying to make something to ask you random multiplication questions. Now
I'm trying to make something pretty simple, but I simply suck at regular expressions.
I am trying to make something that will enable all controls if a SubString
I'm currently in a .NET4 Windows Forms Application. I'm trying to make something like
I am trying to build a Retirement Calculator as a chance to make something
Trying to make a simple program to catalogue books. Something like this, for example:

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.