473,320 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Drop down menu option selected displays a textbox and a button

I have a form with a drop down box. If you select an option in the drop down box (depending which option is selected) one or two textbox(es) and a submit button display.
I would like to keep the textbox(es) and the submit button showing until another option is selected. Also the data that's submitted is showing on the form page.

Here's an example - I need the code below to do this:
1. I go to the page - I see a drop down box.
2. I select the first option - I see the drop down box, a textbox, and a submit button. I submit the info - the drop down box, the same textbox, and the submit button are still visible, with the data below the submit button.
3. I select the second option - I see the drop down box, two textboxes, and a submit button. I submit the info - the drop down box, the same two textboxes, and the submit button are still there with the data below the button, until I select the first option etc.

Here's what I have so far, it works but when I submit the textbox(es) don't show any longer but rather just the drop down box and the data submitted. Thanks for the help in advance.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function toggle(show)
  4. {
  5.     if (this.currvisible) {
  6.         document.getElementById(currvisible).style.display = 'none';
  7.     }
  8.  
  9.     if (show) {
  10.         document.getElementById(show).style.display = '';
  11.         this.currvisible = show;
  12.     }
  13. }
  14.  
  15. </script>
  16.  
Expand|Select|Wrap|Line Numbers
  1. <form method="post" action="index.jsp">
  2.  
  3. <table cellpadding="0" cellspacing="0">
  4.     <tr>
  5.       <td>Make a Selection</td>
  6.    </tr>
  7.    <tr>
  8.       <td>
  9.         <select onchange="toggle(this.options[this.selectedIndex].value);">
  10.             <option value=''></option>
  11.             <option value="d1">d1</option>
  12.             <option value="d2">d2</option>
  13.        </select>
  14.       </td>
  15.       </tr>
  16. </table>
  17. <div id="d1" style="display: none;">
  18.    <table cellpadding="0" cellspacing="0">
  19.      <tr>
  20.          <td>Phone Number</td>
  21.       </tr>
  22.        <tr>
  23.            <td><input name="phoneNumber" /></td>
  24.        </tr>
  25.         <tr>
  26.            <td><input name="submit" type="submit" value="Submit" /></td>
  27.         </tr>
  28.    </table>
  29. </div>
  30.  
  31. <div id="d2" style="display: none;">
  32.        <table cellpadding="0" cellspacing="0">
  33.            <tr>
  34.     <td>Phone Number</td>
  35.            </tr>
  36.     <tr>
  37.         <td><input name="phoneNumber" /></td>
  38.     </tr>
  39.     <tr>
  40.         <td>Email Address</td>
  41.     </tr>
  42.     <tr>
  43.         <td><input name="emailAdress" /></td>
  44.     </tr>
  45.     <tr>
  46.         <td><input name="submit" type="submit" value="Submit" /></td>
  47.     </tr>
  48.   </table>
  49. </div>
  50.   <table>
  51.       <tr>
  52.           <td><c:out value="${param.results}"  /></td>
  53.       </tr>
  54.  </table>
  55. </form>
  56.  
Jun 16 '07 #1
1 5041
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

You could consider AJAX that would allow you to get the data from the server without unloading and reloading the page.
Jun 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ehm | last post by:
I apologize in advance for the cross-post (from microsoft.public.inetexplorer.scripting), but that board seems dead. I have what I think is a fairly simple problem, but I cannot figure this out....
6
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens...
1
by: Greg Scharlemann | last post by:
I would like to automatically populate a drop down menu when the page loads based on the selection of an item in a different drop down menu. I made a test page that when drop down #1 changes, drop...
3
by: JS | last post by:
I have two drop/down menus that are dependant on each other. When I have made a choice in both of these menus and press a button I get to a page depending on the choice made. On this page there is...
19
by: mart2006 | last post by:
I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters what is shown in the dynamic menu....
11
by: vinceboy | last post by:
Hi..guys!I have a drop down menu with javascript null validation.However,instead of clicking submit button,it will immediately auto redirect after option was selected.Is it possible to prevent this...
2
by: giandeo | last post by:
Hello all, It's almost a couple of weeks since i am struggling to get this code work. Unfortunately, i am stuck. There seems to be no hope... Please Help....... I am working with an asp page...
10
by: mart2006 | last post by:
Hi, I'm fairly new to PHP and I've created a dynamic drop down menu that populates itself with data from a MySQL table. What I would like to do is create a non dynamic drop down menu that alters...
6
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.