This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes calling jsp function inside html event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling jsp function inside html event" Watch "calling jsp function inside html event" New topic
Author

calling jsp function inside html event

kamlesh jainani
Greenhorn

Joined: May 09, 2001
Posts: 5
i have a code that looks something like this:
<select name = company
onchange = "showbranchonoption(this.selectedindex); return false;">
the showbranchonoption function is a JSP function. it doesn't work this way. i appreciate any help.. pls..
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

It looks like you're getting confused with server side and client side code.
All JSP code is executed on the server and the result is a HTML page that gets sent to the client. That HTML can contain JavaScript code that gets sent inside the page.
The 'onChange' function is JavaScript which is executed on the clients browser. As such, it has no mechanism to access the JSP code or to change the way the JSP behaves. It is on the client and the JSP code is on the server.
It's allowable to call a JavaScript function embedded in the HTML page though.
Hope this helps,
Dave.
kamlesh jainani
Greenhorn

Joined: May 09, 2001
Posts: 5
my database is in the server, my problem is this: i have two option boxes or a combo boxes that displays the contents of the company table and its branch. each time a user selects a company the branch option box refreshes and displays the corresponding branches of the company selected. my idea was to use a java class for this or a jsp but since you said the event onchange is a javascript hook what is the best way for me to call my function and pass the parameters of my html code
by the way thanks for replying!!
-- kamlesh
Pallavi G
Greenhorn

Joined: May 07, 2001
Posts: 5
Hi there,
I went trhough your reply. In that case if you need to change the contents of one option box, depending on the selection of others (without going to server and refreshing the page again). yo can do it through DHTML, provided you dont have too many records in Database.
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
OR, if you are keen to experiment, you can do remote scripting using a servlet.. here's an overview
http://www-106.ibm.com/developerworks/library/wa-resc/?dwzone=web
I have used this in the past and is a very cool way to do what you want..
[This message has been edited by Mak Bhandari (edited May 11, 2001).]
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"Pallavi G",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
kamlesh jainani
Greenhorn

Joined: May 09, 2001
Posts: 5
hey guys thanks for all ur replies. i'll try mak's suggestion and find my way through it. thanks for all the patience guys...
i'll try to help you guys if i can to return the favor... thanks again...
 
 
subject: calling jsp function inside html event
 
Similar Threads
jsp and javascript
parameter from jsp to javascript function?
Javascript to reach inside a servlet...
jsp
function in JSP