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

which submit button is clicked?

 
qingwu wang
Ranch Hand
Posts: 147
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone!
There are ten submit buttons in my jsp page,how can I get which button to be clicked using script statment.
 
Chris Baron
Ranch Hand
Posts: 1061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using JSP you dont need JavaScript.
You just give all buttons the same name and check for the different values:

With Javascript you can use an onsubmit eventhandler in the form.
With the keyword "this" you access the actual objects (button) properties.
Name or/and value of the buttons should differ so you can use one of these.
Here are 2 ways:
1.In Subm1 the name and value are directly alerted on click.
2.In Subm2 + Subm3 the actual button is written to a variable "clickedbutton" first.
Before submitting the form the function wichbutton() is called with "return".
The form is only submitted if the function's return value is true.
That's good for validating. In this example it's checked if "clickedbutton" is not empty.

hth cb
[ September 14, 2003: Message edited by: Chris Baron ]
 
qingwu wang
Ranch Hand
Posts: 147
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Chris,thanx a lot,I have gotten it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic