Dynamic Form Elements

Posted on 2007-08-06
Medium Priority
Last Modified: 2013-11-24
Is it possible when using a select box to display form elements depending on which option was selected for example:
<option value="d1">Option One</option>
<option value="d2">Option Two</option>
If I selected "Option One" a textbox and a submit button would appear.  For "Option Two" a radio button and a textbox plus a submit button would appear.

If I use a servlet and JSTL and spring how could I get this to work?  I'm new to Java so a detailed description or a tutorial would be great.  I have javascript to make it work but having a problem when submitted the form elements disappear and I have to select option 1 or two again.  

Question by:design_web
  • 2

Author Comment

ID: 19640638
Or I can use Struts if that would be better.  Even though I don't know Struts well either.
LVL 14

Accepted Solution

boonleng earned 1500 total points
ID: 19643071
You don't need struts, struts can't solve this problem as well.

Since you have the javascript to render the textbox and button when selecting the select box, what you need is to execute the javascript during page load (<body onload="..">) and pass in the value of the select box from request parameter/attribute, if the value from request is empty then dont do anything in the javascript.



Author Comment

ID: 19700389
I used the onload.  I wish you would of gave me a little more info because it was a lot more involved but the points are yours.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question