• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do track what link or button was clicked  RSS feed

 
anny johnson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know what link or button was clicked on a jsp page that i create and lets say it has several links but i want to set a variable depending on what button was clicked. how do i track what button was clicked cause i want it to call it's page of origin but just a chuck of code changes on that same page depending on what button was clicked. So any idea on how to track a button or link, thanks
anny
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anny
If it is from an html form then the button should have a name and you can then just cycle through them all to see which one was clicked. Or name them all the same but give them different values then just get the value for the button that was clicked and then loop through to see which one it was.
You'd use the getParameter method of the HttpServletRequest object to get the value that was submited on the form.
hope that does it for you
 
Byron Estes
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dave Vick:
Anny
If it is from an html form then the button should have a name and you can then just cycle through them all to see which one was clicked. Or name them all the same but give them different values then just get the value for the button that was clicked and then loop through to see which one it was.
You'd use the getParameter method of the HttpServletRequest object to get the value that was submited on the form.
hope that does it for you

The only way I can think of to do this with links is to use JavaScript and the onclick event. You can have a form (it maybe just hidden) that you can use to hold your variables. The onclick event of the link could pass in a parameter identifying itself. The method would modify the variables as needed based upon other parameters passed in by the onClick call or they could be coded statically in the method. After all this is done, the method would submit the hidden form and viola!
Regards,
Byron Estes
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!