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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:53:53+00:00 2026-05-27T02:53:53+00:00

I have a form that the user can save and return to edit. I

  • 0

I have a form that the user can save and return to edit. I have questions on the form that toggle a div based on the user’s answer to a previous question. There are multiple of these question types. If the answer is ‘yes’, the div for that question should display.

Currently, the divs are displaying on the form load, when they should be hidden.

Example: http://jsfiddle.net/BbrwT/14/ (I setup example so question one has not been answered yet, where question two has been answered ‘no’)

<div>
    <label>Select #1:</label>
    <input type="radio" name="radio1" class="toggle" value="1">Yes
    <input type="radio" name="radio1" class="toggle" value="0">No
</div>

<div id="details">
   Details #1
</div>

<div>
    <label>Select #2:</label>
    <input type="radio" name="radio2" class="toggle" value="1">Yes
    <input type="radio" name="radio2" class="toggle" value="0" checked="checked">No
</div>

<div id="details">
   Details #2
</div>

Javascript:

$(document).ready(function() {

    if($('.toggle:checked').val() != 1){
        $(this).parent().next('#details').hide()
    }

    $('.toggle').on('change',function(){

        var showOrHide = ($(this).val() == 1) ? true : false;

        $(this).parent().next('#details').toggle(showOrHide);

    })  

});
  • 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-27T02:53:54+00:00Added an answer on May 27, 2026 at 2:53 am

    Not sure if this is what you want, but you could chain the change method on to your change handler –

    $('.toggle').on('change',function(){
    
        var showOrHide = false;
    
        $(this).siblings('input[type=radio]').andSelf().each(function() {
            if ($(this).val() == 1 && $(this).prop("checked")) showOrHide = true;
        })    
    
        $(this).parent().next('#details').toggle(showOrHide);
    
    }).change()  
    

    That should call the change method on loading the page and hide anything that your logic states should be hidden. I’ve also changed logic slightly so the values of sibling radio buttons are also checked.

    Demo – http://jsfiddle.net/sBErV/2/

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

Sidebar

Related Questions

I have a form that the user can save and return to edit. I
I have a form that the user can save and return to edit. I
i have a form that has a multiple select drop down. a user can
I have a view user control that can post form. This control can be
I have a page which displays a form that a logged-in user can use
I have a registration form that a user can access via invitation. For example,
So I have a form that accepts some input from a user that may
We have a form that allows a user to filter a list with by
I have a form that allows a user to import a spreadsheet. This spreadsheet
I currently have form that checks if a user has unsubmitted changes when they

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.