• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Pass selected drop down list value to method  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may be a simple thing, but I am trying to capture the selected value from a drop down list on an JSP page and use the selected value as an argument to a method. I am able to use the onchange event in the select tag to call a java script function and capture the value but I am not sure how to send the value to the method. I think there is a way to do this via an ajax based call but I am not sure how to accomplish this. To be clear this code runs but I don't know how to pass the value to a method on the JSP page. Here is a sample of the test code I am using. Thank you.

 
Ranch Hand
Posts: 207
2
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to call a method with javascript or what?  What do you want to do with the value?  You could just a button, or use angular to auto update the dom.
 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angular is an advanced JavaScript framework that's well beyond the scope of this question.

The problem is on your onchange declaration. You are calling the function rather than declaring it as the change event handler. Remove the parentheses; you want a reference, not a call.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two other things:
  • You originally posted this in a Java forum before it was moved to the HTML/JavaScript forum. Java and JavaScript have nothing to do with one another, despite the similarity in names.
  • Your script and markup is poorly formatted. Be sure to use proper indentation when writing any programming language; include HTML and JavaScript.
  •  
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!