This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes JSP functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JSP functions" Watch "JSP functions" New topic

JSP functions

Karl Dowling

Joined: Mar 31, 2004
Posts: 2
i have list box in a form that is pulling data from a mysql db. when i click on an item in the list box i want data to change in other text boxes in the form. i have most of the code to it......BUT... i need to put that code into a function and call it in the onChange event in the form. i have tried to do this but ikeep getting the following error:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 18 in the jsp file: /Administrator/addPromotion.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\tomcat\work\Catalina\localhost\_\org\apache\jsp\Administrator\ ';' expected
function ChangeDynamicData(){
1 error

im just not too sure how to structure my function and how to call it.
any replies would be greatly appreciated!!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

You are mixing up Java functions and Javascript functions. The onchange handler requires a Javascript function.

[Asking smart questions] [About Bear] [Books by Bear]
Karl Dowling

Joined: Mar 31, 2004
Posts: 2
is there a way to refresh the browser in the onChange event?
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
You can do this all with javascript, you want to stay away from JSP for this one. Your onChange() event is controlled by javascript, so, in your onChange() function, you can simply use javascript to replace the values in the fields you want to change. So for instance, assume I have the following bit of code:

When you click the button, the text in the textarea will change. You can use these scheme to change DOM components dynamically.
NOTE: onKlick() has been changed to conform to the Ranch posting requirements -- it should be spelled with a C, of course.
[ April 01, 2004: Message edited by: Winston Smith ]

for (int i = today; i < endOfTime; i++) { code(); }
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

Quite correct; there is no need for server-side activity to accomplish this.
I'm moving this to the HTML/Javascript forum for any further discussion.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
refreshing the browser:
[ April 01, 2004: Message edited by: Eric Pascarello ]
I agree. Here's the link:
subject: JSP functions
It's not a secret anymore!