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
- <script type="text/javascript">
- function toggle(show)
- {
- if (this.currvisible) {
- document.getElementById(currvisible).style.display = 'none';
- }
- if (show) {
- document.getElementById(show).style.display = '';
- this.currvisible = show;
- }
- }
- </script>
Expand|Select|Wrap|Line Numbers
- <form method="post" action="index.jsp">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <td>Make a Selection</td>
- </tr>
- <tr>
- <td>
- <select onchange="toggle(this.options[this.selectedIndex].value);">
- <option value=''></option>
- <option value="d1">d1</option>
- <option value="d2">d2</option>
- </select>
- </td>
- </tr>
- </table>
- <div id="d1" style="display: none;">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <td>Phone Number</td>
- </tr>
- <tr>
- <td><input name="phoneNumber" /></td>
- </tr>
- <tr>
- <td><input name="submit" type="submit" value="Submit" /></td>
- </tr>
- </table>
- </div>
- <div id="d2" style="display: none;">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <td>Phone Number</td>
- </tr>
- <tr>
- <td><input name="phoneNumber" /></td>
- </tr>
- <tr>
- <td>Email Address</td>
- </tr>
- <tr>
- <td><input name="emailAdress" /></td>
- </tr>
- <tr>
- <td><input name="submit" type="submit" value="Submit" /></td>
- </tr>
- </table>
- </div>
- <table>
- <tr>
- <td><c:out value="${param.results}" /></td>
- </tr>
- </table>
- </form>