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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:16:13+00:00 2026-05-18T01:16:13+00:00

I need to register a handler for a group of radio buttons. I’m using

  • 0

I need to register a handler for a group of radio buttons. I’m using JQuery and hoped that its .change method would accomplish this. However I have not experienced the desired behavoir.

Here is a sample snippet I’ve written. Sadly, the “radioValueChanged” is only called on the initial load. Selecting either true / false does not trigger the handler.

<html>
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>

<form id="myForm">
    <div id="Question1Wrapper">
        <div>
            <input type="radio" name="controlQuestion" id="valueFalse" value="0" />
            <label for="valueFalse">
                False</label>
        </div>
        <div>
            <input type="radio" name="controlQuestion" id="valueTrue" value="1" />
            <label for="valueTrue">
                True</label>
        </div>
    </div>
    <div id="Question2Wrapper">
        <div>
            <label for="optionalTextBox">
                This is only visible when the above is true</label>
            <input type="text" name="optionalTextBox" id="optionalTextBox" value="" />
        </div>
    </div>

    <script type="text/javascript">
        jQuery(document).ready(function ()
        {
            $("#controlQuestion").change(radioValueChanged('controlQuestion'));
        })

        function radioValueChanged(radioName)
        {
            radioValue = $('input[name=' + radioName + ']:checked', '#myForm').val();

            alert(radioValue);

            if(radioValue == 'undefined' || radioValue == "0")
            {
                $('#Question2Wrapper:visible').hide();
            }
            else
            {
                $('#Question2Wrapper:visible').show();
            }
        } 
    </script>
</form>

  • 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-18T01:16:13+00:00Added an answer on May 18, 2026 at 1:16 am

    There are a few issues here.

    1. You are immediately running radioValueChanged('controlQuestion') upon script execution because that is a method call and not a function assignment.

    2. The selector $("#controlQuestion") is wrong, you don’t have any elements with id of controlQuestion.

    3. The radioValueChanged method is not properly handling values as they would be passed to a jQuery event handler.

    You could try something like the following:

    jQuery(document).ready(function ()
        {
            $("input[name='controlQuestion']").change(radioValueChanged);
        })
    
        function radioValueChanged()
        {
            radioValue = $(this).val();
    
            alert(radioValue);
    
            if($(this).is(":checked") && radioValue == "0")
            {
                $('#Question2Wrapper').hide();
            }
            else
            {
                $('#Question2Wrapper').show();
            }
        } 
    

    In all honesty I’m not sure if that is the actual logic you are looking for with the if statement, but hopefully this will provide a basis for you to correct the current code.

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

Sidebar

Related Questions

I have a new service that I have written and need to register it
i am developing register form using php where i need to upload the file
How to make activities that register BroadCastReceiver? Because I need to close all the
I need to register an Event Handler for a class which is generated by
Where best place to register event handlers when using MVP paradigm? I know that
I need to write some code that registers an event handler for the SiteMapResolve
I have a lot of handler classes that handle specific message types. To register
I would like to confirm something - when I register a method as a
I need a function(eg signal handler) in C/C++ linux that gets activated every 'n'
I need to register a file type (e.g. .exex files) when my application is

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.