File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Populating one drop down based on the other Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Populating one drop down based on the other" Watch "Populating one drop down based on the other" New topic
Author

Populating one drop down based on the other

sree visu
Ranch Hand

Joined: Jul 05, 2007
Posts: 133
I am using JSTL to populate one dropdown based on the selection of the other dropdown

Here is what i did:

In the form element tag i have a drop down named manufact that gets populated(and works correctly).But i would like to get the selected value of this dropdown and
populate the second drop down named providedfor.I have used the window.location.reload which reloads the form.But i don't understand why the <sql:param> tag does not get filled with the value of the
param.manufact ( as shown by numbering (1) and (2).Is there any mistake? Please help

The HTML form elements:


Now the JSTL sql tags



Thanks for your help in advance


Regards<br />Sree Visu<br />SCJP 5.0, SCWCD 5.0, SCJD(Preparing B&S 2.2.2)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Personally, I would use an Ajax solution for this, and would never use the SQL JSTL tags.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sree visu
Ranch Hand

Joined: Jul 05, 2007
Posts: 133
Thank you bear bibeault,
but i am a newbie to ajax and i am not clear in its concepts.Could you please tell me how to do it with JSTL and SQL tags.To be the minimum how would you save a particular form element after it is getting reloaded so that i can use it in my (2) as mentioned in my previous post.Sorry that i do not know ajax and it is not an issue if my form gets reloaded.Please help me to fix it...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

The SQL tags are not intended for production use and I do not think you should be relying upon them.

If you want to use a pure JSP solution (rather than Ajax), that's fine (just less efficient), but you should do so by following best practices and sequestering any DB access to Java model classes.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
If Ajax is one step too high and you want to do it all asynchronously, then just print all possible options out into a Javascript array variable and use Javascript to populate the dropdown.
sree visu
Ranch Hand

Joined: Jul 05, 2007
Posts: 133
Thank you Bauke Scholtz and Bear Bibeault for your reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Populating one drop down based on the other