aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes which submit button is clicked? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "which submit button is clicked?" Watch "which submit button is clicked?" New topic
Author

which submit button is clicked?

qingwu wang
Ranch Hand

Joined: Feb 19, 2003
Posts: 147
Hello everyone!
There are ten submit buttons in my jsp page,how can I get which button to be clicked using script statment.


Thanks...qingwu<br />When I open my eyes,I see your pretty face.
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
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

Joined: Feb 19, 2003
Posts: 147
Thanx Chris,thanx a lot,I have gotten it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which submit button is clicked?
 
Similar Threads
question about object casting
Which submit is pressed
How to know which submit button is pressed in JSP for BaseLookupDispatchAction
multiple submit buttons
multiple submit buttons and jsp