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

  • Home
  • SEARCH
  • 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 3939248
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:16:41+00:00 2026-05-20T00:16:41+00:00

I have a drop-down selector and form fields below. I need to be able

  • 0

I have a drop-down selector and form fields below. I need to be able to display form labels and corresponding form fields based on selected option.

What is the best way to implement this: prepare possible labels and fields and forms elements and store them in hidden divs and then show/hide based on selection?

<script type="text/javascript">
$(function() {
    $('#mySelector').change(function(){            
         $('.opt').hide();
         $('#' + $(this).val()).toggle();
    });
});
</script>

<select id="mySelector">
   <option value="o1">Car details
   <option value="o2">Boat details
   <option value="o3">Train details
</select>

<div id="o1" class="opt">
    <label for="f1_1">Car speed</label>
    <input id="f1_1" type="text">
    <br>
    <label for="f1_2">Car color</label>
    <input id="f1_2" type="text">
</div>

<div id="o2" class="opt">
    <label for="f2_1">Boat size</label>
    <input id="f2_1" type="text">
    <br>
    <label for="f2_2">Boat weight</label>
    <input id="f2_2" type="text">
</div>

<div id="o3" class="opt">
    <label for="f3_1">Train length</label>
    <input id="f3_1" type="text">
    <br>
    <label for="f3_2">Train cargo</label>
    <input id="f3_2" type="text">
</div>

I assume jQuery is the best way to go…

Also, I will display this 3 times, once for each option. I need some sort of mechanist to prevent selecting the same option that has been selected above. Is it possible?

  • 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-20T00:16:41+00:00Added an answer on May 20, 2026 at 12:16 am

    If the ‘weight’ of these elements is light then putting them in your page and dynamically toggling which is visible is not a bad idea. Otherwise, you probably should fetch the content via ajax.

    $('#o1').show()  // This will display the 'o1' div
    $('#o1').hide()  // This will hide the 'o1' div
    

    I would probably add a class (maybe ‘info’ to each of the divs). That way you can use

    .info {display: none; }
    

    to initially hide the elements and

    $('.info').hide() // this will hide all the elements.
    

    If you need to use ajax, you probably will need a placeholder div…

    <div id='placeholder'></div>
    

    and use

    $('#placeholder').load(url)
    

    to dynamically fetch the html.

    Hope this gets you started.

    Bob

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

Sidebar

Related Questions

Suppose I have a drop-down list like: <select id='list'> <option value='1'>Option A</option> <option value='2'>Option
I have a drop down like this on my page: <p> <%= f.label :episode_id
I have a drop down menu and it works perfectly on everything except IE6
I have a drop-down list with known values. What I'm trying to do is
On my page I have a drop-down select box, with a default value of
This would be my issue I have a drop down that's not displaying fully.
Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have
I've run on a little problem today: I have a JS drop down menu
We have a series of drop down controls that determine the sort order of
I have an ASP.NET Datagrid with several text boxes and drop down boxes inside

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.