File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes A drop down menu that decides the fate of other drop down menus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "A drop down menu that decides the fate of other drop down menus" Watch "A drop down menu that decides the fate of other drop down menus" New topic
Author

A drop down menu that decides the fate of other drop down menus

Rajdeep Biswas
Ranch Hand

Joined: Mar 26, 2012
Posts: 186

Hi,
I need a help in Javascript.

There are three drop down boxes, namely, A, B and C.
A -> enable / disable
B -> Choco / Vanilla / Butter scotch
C -> Cup / Shake

The default value of A will be "disable", so that the B and C menus are disabled, and with null values by default and will not show anything but a disabled, grayed out blank drop down box, when the form is submitted.
When A is set to "enable", then B and C are also enabled for the user, and there will no be null for them this time.
Because when A is disabled, I have to include null as default value for B and C in select option, and when A is enabled then the null will also come as an option for the user.
Please guide me on how to achieve this. Sincere thanks.


The biggest gamble will be to ask a question whose answer you know in that it will challenge your theory | www.TechAspire.blogspot.in
Shashank Gollapudi
Ranch Hand

Joined: Jan 19, 2012
Posts: 33
Use an onchange event for your dropdown named A and make an AJAX call and based upon the response it sends, populate them as <option> fields for the respective <select> tags.

Please let me know, if something is unclear
Rajdeep Biswas
Ranch Hand

Joined: Mar 26, 2012
Posts: 186

I have no idea of AJAX and here, the code is very bad in design. Not html is JSP but Java code. Its like all field details are in Map, and this Map is passed onto some class, which then parses the values and does out.println("..."); for writing the code. So I have to be very careful here, as I do not want to break the existing design. To change the values I have written onChange() already in the parsing Java class, and its working also. The main issue is that when A is disabled, B and C should not show anything and should be disabled, and pass NULL to underlying commands to be saved onto DB, but when A is enabled, then proper options are displayed in B and C drop-downs, and no blank space is shown.
Rajdeep Biswas
Ranch Hand

Joined: Mar 26, 2012
Posts: 186

Or can I do something like a multi select box. For A's disable option, only null or blank B and C options are available and disabled. When A is enabled, then all other options are displayed rather that blank option. I have no idea of this also.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A drop down menu that decides the fate of other drop down menus