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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:10:35+00:00 2026-06-09T23:10:35+00:00

I just started learning JS and jQuery and have a question. I want to

  • 0

I just started learning JS and jQuery and have a question. I want to make a dynamic form which can be complex with more then one Selector. The problem is when I open Option1 and then press the other selector with option6 and 7 it disappears but I want it to be visible. I know the problem is the $(‘label’).hide(); but I’m so bad at jQuery and Jscript that I don’t know how to make this work. I would appreciate any help with this.

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
    $('label').hide();
    $('#sel').change(function() {

        var val = $(this).val();

        $('label').hide();

        switch (val){
            case 'option1':
                $('#label1').show();
                break;
            case 'option2':
                $('#label2').show();
                break;
            case 'option3':
                $('#label3').show();
                break;
            case 'option4':
                $('#label4').show();
                break;
            case 'option5':
                $('#label5').show();
                break;

        }
    });

    $('#sel2').change(function() {

        var val = $(this).val();

        $('label').hide();

        switch (val){
            case 'option6':
                $('#label6').show();
                break;
            case 'option7':
                $('#label7').show();
                break;        
        }
    });


    $("input")
        .focus(function () {
            $(this).next("span").fadeIn(1000);
        })
        .blur(function () {
             $(this).next("span").fadeOut(1000);
        });
});
</script>


<style>
label {
    display:block;
}
</style>
</head>

<body>

<form>
    <select id="sel">
        <option value="">- select -</option>
        <option value="option1">Option 1</option>
        <option value="option2">Option 2</option>
        <option value="option3">Option 3</option>
        <option value="option4">Option 4</option>
        <option value="option5">Other</option>
    </select>

    <label id="label1">
        <select id="sel2">
            <option value="">- select -</option>
            <option value="option6">Option 6</option>
            <option value="option7">Option 7</option>
        </select>
    </label>

    <label id="label2" for="option2">Text box label 2
        <input type="text" id="option2" />
    </label>
    <label id="label3" for="option3">Text box label 3
        <input type="text" id="option3" />
    </label>
    <label id="label4" for="option4">Text box label 4
        <input type="text" id="option4" />
    </label>
    <label id="label5" for="option5">Other
        <input type="text" id="option5" />
    </label>

    <label id="label6" for="option6">Text box label 6
        <input type="text" id="option6" />
    </label>
    <label id="label7" for="option8">Text box label 7
        <input type="text" id="option7" />
    </label>


</form>

</body>
</html>
  • 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-09T23:10:37+00:00Added an answer on June 9, 2026 at 11:10 pm

    When you call #sel2, you keep hiding ‘label’ every time (which includes itself). I would change it to:

    $('#sel2').change(function() {
    
        var val = $(this).val();
    
        $('#label6').hide();
        $('#label7').hide();
    
        switch (val){
            case 'option6':
                $('#label6').show();
                break;
            case 'option7':
                $('#label7').show();
                break;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning Jquery and am new to writing javascript (I am
I've just started learning jQuery/javascript, so this might seem like a really basic question,
Question 1 I've just started learning jQuery and one thing that puzzles me is
Just started learning Jquery - here's my problem: I have six divs on a
I've just started learning javascript and have created a drag and drop using jquery
Just started learning python (3.2) and have a question. I have created a some
Just started learning x64 assembly and I have a question about functions, arguments, and
I've just started learning Jquery but the examples aren't helping me much... Now whats
I started learning jQuery just yesterday, and I like it very much. And now
I just started learning targets, and have followed all the instructions to create my

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.