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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:50:21+00:00 2026-05-20T09:50:21+00:00

I want to display a series of textboxes for additional input depending on the

  • 0

I want to display a series of textboxes for additional input depending on the the user’s selection from a drop down list. When option1 is selected, one textbox appears for additional input. Option2 requires 3 textboxes, option3 needs 2 textboxes, option4 and other require one textbox each.

I have pieced together some code from researching other threads and have come up with the code found here: http://jsfiddle.net/zFQf3/

Can anyone please provide direction?

Thank you.

  • 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-20T09:50:21+00:00Added an answer on May 20, 2026 at 9:50 am

    I redid what you had on jsFiddle (http://jsfiddle.net/zFQf3/29/ or http://jsfiddle.net/zFQf3/47/ if you want a class based solution), but I am not sure how to use that site, so I don’t know if it saved. I will copy and paste it here too just in case.

    I modified your HTML to this:

    <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="other">Other</option>
        </select>
        <label id="label1" for="option1">Text box label 1
            <input type="text" id="option1" />
        </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>
    </form>
    

    I added some CSS just for visibility sake:

    label {
        display:block;
    }
    

    I modified your JS to this:

    $(function() {
        //This hides all initial textboxes
        $('label').hide();
        $('#sel').change(function() {
            //This saves some time by caching the jquery value
            var val = $(this).val();
            //this hides any boxes that the previous selection might have left open
            $('label').hide();
            //This just opens the ones we want based off the selection
            switch (val){
                case 'option1':
                case 'option4':
                case 'other':
                    $('#label1').show();
                    break;
                case 'option2':
                    $('#label1').show();
                    $('#label2').show();
                    $('#label3').show();
                    break;
                case 'option3':
                    $('#label1').show();
                    $('#label2').show();
                    break;        
            }
        });
        //I'm not really sure why these are here
        $("input")
            .focus(function () {
                $(this).next("span").fadeIn(1000);
            })
            .blur(function () {
                 $(this).next("span").fadeOut(1000);
            });
    });
    

    I think that does what you want.

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

Sidebar

Related Questions

I want display data from database in Listbox...Here is my code, It is not
i want display 1 record from colums zodys , I'm programint in C# I
I want to display a series of text in an animated way one after
I have a series of svg rectangles (using D3.js) and I want to display
I want to display series of images one by one when the app loads.
I want to display 3 series on my Silverlight toolkit horizontal bar chart...2 normal
I'm trying to display a series of titles varying from 60 characters to 160
I want to display a series of my own descendent class of View in
I have a series of imageviews that I want to display, but on a
I am DataTemplating a listbox's ItemSource to display a series of comboboxes. I want

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.