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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:10:09+00:00 2026-05-23T19:10:09+00:00

My code works beautfiully it shows when I need it to show and hides

  • 0

My code works beautfiully it shows when I need it to show and hides when I need it to go away. The idea here is that when using the form the person who is using it can check a box, see more required form data for what they just checked, it makes those fields required, and when that user unchecks the box it goes away.

The only problem is when a user clicks radio box within the group but the radio box does not have the correct value to show the container container (ex my false condition) jQuery will very quick show the box, then hide it again. Is there a way within my code to keep the box hidden if it’s not the correct condition, and if they switch to a different box, it’ll hide the box the user was looking at? If so how?

Here’s my code:

        var hiddenClassArray = [
                    "appliedWorkedYes",
                    "workStudyYes",
                    "workHistoryYes",
                    "workWeekEndsYes",
                    "cprYes",
                    "aedYes",
                    "aidYes",
                    "lifegaurd",
                    "wsiYes",
                    "gaurdYes",
                    "lifegaurdChk",
                    "fitnessChk",
                    "fitPTCYes",
                    "fitGrpYes",
                    "outdoorAdvChk",
                    "challengeChk",
                    "injuryCareChk",
                    "athTrainYes",
                    "serviceCenter",
                    "itDepartmentChk",
                    "marketingChk", 
                    "personalTrainer",
                    "yogaInstructr",
                    "IndoorCyclingInstructr",
                    "grpFitInstruct",
                    "pilatesInstructr",
                    "itDepartmentChk",
                    "marketingChk",
                    "yogaInstructr",
                    "cyclingInstructr",
                    "personalTrainerChk",
                    "yogaInstructorChk",
                    "IndoorCyclingInstructorChk",
                    "grpFitInstructChk",
                    "pilatesInstructChk",
                    "itDepartmentChk2",
                    "climbAssistant",
                    "priorWrkName",
                    "priorWrkSalary",
                    "priorWrkTitle",
                    "priorWrkSupervisor",
                    "priorWrkStartDate",
                    "priorWrkEndDate",
                    "priorWrkReasonForLeaving",
                    "officeUseStatus"
                    ];  

        // looping over each array element, hiding them using jQuery
        for(var i = 0; i < hiddenClassArray.length; i++){
            // jQuery to append a display none. 
            $("."+hiddenClassArray[i]+"Hide").css("display","none");    
        }

        // ************ RADIO & CHECK BOXES ************

    // jQuery's Equlivant of a for each loop, a little fancier then that 
    // This appears to work better then the for loop above, but the for loop above
    // has no problems but it did for this set. 
    $.each(hiddenClassArray, function(index, radio) {

        // first is it a Check box? 
        if($("."+radio).is(':checkbox')) {
            // when we click
            $("." + radio).click(function() {
                // if it's checked show
                if($("."+ radio).attr('checked')){
                    // show
                    $("." + radio + "Hide").show('fast'); 
                    // make one of the group required
                    $("."+ radio + "Required").addClass("required");
                }
                // default hide
                else{ 
                    // hide 
                    $("."+ radio + "Hide").hide("fast");
                    // remove the required class attribute
                    $("."+ radio + "Required").removeClass("required");
                }
            }); // ends .click
        } // ends if
        // if it's a radio box
        else if ($("."+radio).is(':radio')) {
            // On click
            $("."+radio).click(function(){
                // show
                if($(this).val()==="True"){                         
                    // show
                    $("."+radio + "Hide").show("fast");
                    // make one of the group required
                    $("."+radio + "Required").addClass("required");
                    alert("Got here ! ");
                }
                else if($(this).val()=="nc"){
                    $("."+radio + "Hide").show("fast");
                }
                // default, hide
                else{ 
                    // hide
                    $("."+radio + "Hide").hide("fast");
                    // remove the required class attribute
                    $("."+radio + "Required").removeClass("required");
                }
            }); // emds .click

        }// ends else
    }); // end .each
  • 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-23T19:10:10+00:00Added an answer on May 23, 2026 at 7:10 pm

    Try to replace the below code

    $.each(hiddenClassArray, function(index, radio) {

        // first is it a Check box? 
        if($("."+radio).is(':checkbox')) {
            // when we click
            $("." + radio).click(function() {
                // if it's checked show
                if($("."+ radio).is(':checked')){
                    // show
                    $("." + radio + "Hide").show(); 
                    // make one of the group required
                    $("."+ radio + "Required").addClass("required");
                }
                // default hide
                else{ 
                    // hide 
                    $("."+ radio + "Hide").hide();
                    // remove the required class attribute
                    $("."+ radio + "Required").removeClass("required");
                }
            }); // ends .click
        } // ends if
        // if it's a radio box
        else if ($("."+radio).is(':radio')) {
            // On click
            $("."+radio).click(function(){
                // show
                if($(this).val()==="True"){                         
                    // show
                    $("."+radio + "Hide").show();
                    // make one of the group required
                    $("."+radio + "Required").addClass("required");
                    alert("Got here ! ");
                }
                else if($(this).val()=="nc"){
                    $("."+radio + "Hide").show();
                }
                // default, hide
                else{ 
                    // hide
                    $("."+radio + "Hide").hide();
                    // remove the required class attribute
                    $("."+radio + "Required").removeClass("required");
                }
            }); // emds .click
    
        }// ends else
    }); // end .each
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works in a windows forms application (it shows the preview) but not
This code works (C# 3) double d; if(d == (double)(int)d) ...; Is there a
My code works great in IE8, Firefox and Safari. But it doesn't work properly
My code works (yeah!) which sends json to a server.. would appreciate any thoughts
This code works fine: $result = $client->__call(optionalInfo, array( new SoapParam(..., client), new SoapParam(..., add_code))
This code works, but i dont understand why. With DeferredLoadingEnabld = false, I would
My code works. After I copy about 10 tables I get an error. Dynamic
This code works correctly to make a web service call: int numberOfGuests = Convert.ToInt32(search.Guest);
This code works: monkey.h @interface monkey : NSObject { NSNumber *monkeyRanch; } @property (nonatomic,
This code works (when ControlType=dropDown then the background yellow ): <Window x:Class=TestCollapsed.Views.MainView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

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.