GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes which 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 button is clicked" Watch "which button is clicked" New topic
Author

which button is clicked

deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
i creates multiple buttons on jsp through loop.
now i want to access which button is clicked
how can i do it?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

Your post is too vague to give a substantive answer to.

What kind of buttons? Where do you need to know, client or server? etc...


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3833

For HTML, "onclick" attribute of each button (input tag) you can call a Javascript function passing a value which identifies the button clicked.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
for(int i=0;i<5;i++)
{
%>
<input type="button" onclick="fun1()">
<%
}



<script type="text/javascript">
function fun1()
{
//what code should be written here
}

</script>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

OK, so this is a JavaScript question... Please take the time to choose the correct forum for your posts. This forum is for questions on XYZ. For more information, please read this.

This post has been moved to a more appropriate forum.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

You're easiest course would be to use separate handlers for each button.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Pass the object:






Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: which button is clicked