• 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

Getting the values of a dynamic(javascript) HTML Select

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

It's been a while since I've used Struts.

I happen to have two html:select elements, A and B respectively. They are both of type String[] in my ActionForm.

Now, A gets poppulated dynamically by me by iterating through a request variable (a List, actually).

B initially doesn't have any values, its values are dynamically generated through Javascript. Basically, B gets its option elements from A using Javascript.

Now, when I get to my Action class, I get a NullPointerException. It seems that B doesn't get its value at all although I am setting the property for it. Here are some code snippets.

Please excuse my caps, they're not meant to mean that I'm shouting.



Is it important the I set the <option> tag's ID or Name attribute in plain old HTML during the Javascript process? Thanks!
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an HTML oddity. Select fields are intended to display a list of items and one picks the values they wanted by selecting one or more. What you want to do is submit all the values in a particular select field. The solution is to use javascript to select all the values in that field before submitting the form.
 
reply
    Bookmark Topic Watch Topic
  • New Topic