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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:33:59+00:00 2026-05-27T02:33:59+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 (class = "details) with additional questions based on the user’s answer to the previous question. There are multiple of these question types.

I’d like the answers of the sub-questions within the details div to clear if the user selects ‘no’ (when the sub-questions are toggled to hidden). How would I implement that into my existing code?

Example: http://jsfiddle.net/XVtB8/1

jQuery:

$('.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()  

HTML:

<div>
    <label>Select #1:</label>
    <input type="radio" name="radio1" class="toggle" value="0">No    
    <input type="radio" name="radio1" class="toggle" value="1" checked="checked">Yes
</div>
<div id="details">
   <input type="text" value="123"><br>
   <input type="text" value="456">
</div>

<br>

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

<br>

<div>
    <label>Select #3:</label>
    <input type="radio" name="radio3" class="toggle" value="0" checked="checked">No    
    <input type="radio" name="radio3" class="toggle" value="1">Yes
</div>
<div id="details">
   <input type="text"><br>
   <input type="text">
</div>

<br>

<div>
    <label>Select #3:</label>
    <input type="radio" name="radio4" class="toggle" value="0">No    
    <input type="radio" name="radio4" class="toggle" value="1">Yes
</div>
<div id="details">
      <input type="text"><br>
      <input type="text">
</div>
  • 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:33:59+00:00Added an answer on May 27, 2026 at 2:33 am

    You can try something like this:

    $('.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);
    
    if (showOrHide==false){
        $(this).parent().next('#details').find('input[type=text]').val('');
        $(this).parent().next('#details').find('input:checkbox').removeAttr('checked');
    
        // other fields type to clear   
    
    } }).change() 
    

    here is un updated fiddle : http://jsfiddle.net/XVtB8/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 form where a user can enter the number of students that
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 the user fills out, when submitted an new
So I have a form that accepts some input from a user that may
I have a form that allows a user to import a spreadsheet. This spreadsheet
I have a form that enables a user to update multiple alert rules records

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.