If you enter a text string in an HTML TEXT control and you then want to go to another JSP page and dymamically create/populate some values in a "list" of some kind, ***based on what the user entered on the last JSP page***, is this HTML, DHTML, or something else? I'm not asking about "how" to get the data. Assume that in the second JSP page, I already have the data, but need to populate some kind of "picker" control, on the fly, that the user can use to choose the fields (values) he wants. I'm not sure how to create a list on the fly. I am using a bean to return the database results, and that part works fine. I appreciate anyone's input on this. Thanks. -- Mike
Assumption: First page selects cola manufacturer Second page lists beverages made by the selected manufacturer.
You've already got the dynamic list of drinks, right? You told us to assume you had the data already.
If you already have the beverage list, then loop over the data, outputting checkboxes of the same name, but with different values (for example, the primary key of each drink). Another control you could use is the select control with multiple="multiple" attribute set. The loop would then be producing multiple option tags with different values.
Once this is submitted, it would be an array with the name of the checkboxes (or the select control), and would contain the primary key of only those drinks picked by the user from the list provided.
last little bit: If you 'already have the data', but that data is not already 'filtered' based on what the user had previously selected... so in my example, the user selects "pepsico international", but the list of drinks on the next page contains drinks by coca-cola, then I'd suggest re-writing your SQL query. Your query should return results based on the first selection. [ July 25, 2002: Message edited by: Mike Curwen ]
Joined: Jul 12, 2002
Sorry I haven't been more clear. Yes, the SQL works fine and correctly as you indicated it should. I wasn't focusing on the SQL. My issue is how do you populate a HTML list at runtime? Is this just a JSP loop where you populate some HTML control? Thanks.
Mike sounds like you're looking for a select list, in html the form it tales is:
IF you want the client to be able to select mopre than one option at a time then use the multiple option in the tag: <select name="name" multiple> When the user selects options and submits the form they'll come to the JSP or servlet as parameters of the HttpRequest. so to dynamically create one, just get your data, create the initial tag, then loop through your data and generate the option tags, then close the switch tag. hope that helps