File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling jsp function inside html event

 
kamlesh jainani
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
kamlesh jainani
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic