• 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

Populating dropdowns without submitting form

 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All -

I have a question. Suppose I have 2 dropdowns, based on the value selected from 1st dropdown, the second dropdown gets populated. Both the dropdowns are getting populated from DB or web service.

Is there anyway i can achieve it without submitting the form and reloading the page in Struts. (NOTE: My browser doesn't support AJAX or I do not want to use AJAX).

Thanks,
Grishma
[ January 04, 2008: Message edited by: Grishma Dube ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One possible way to do this would be to pre-populate JavaScript arrays for the second dropdown based on all possible values of the first dropdown box. You could then use JavaScript to swap out the values of the second dropdown without using AJAX and without submitting the form.

However, your statement about your browser not supporting AJAX is probably not true. If your browser supports any type of JavaScript, it also supports AJAX.
[ January 04, 2008: Message edited by: Merrill Higginson ]
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you cannot or do not want to use Ajax then the only other way that I know to do this is with JavaScript. An Internet search will surely turn up several examples. A JavaScript solution works fine as long as your total list of values is fairly small. A previous project of mine used JavaScript for smaller lists and page refreshes for larger lists. I think the cutoff for "larger" was around 1000 expected items.

Edit: I see Merrill posted while I was typing my response. I will add this...part that can be confusing about the JavaScript approach for dynamic data is that you will be using Java code or tags in your JSP code to create the JavaScript code. For some reason I always get confused when I have to mix the two together.

- Brent
[ January 04, 2008: Message edited by: Brent Sterling ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic