Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Populating dropdowns without submitting form

 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • 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 ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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 ]
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic