• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 233
1
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic