By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,321 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,321 IT Pros & Developers. It's quick & easy.

How to know which button is clicked in JSP

P: 14
Hi,

I am using a JSP in my application. In JSP page I created tables and buttons inside a loop.
Expand|Select|Wrap|Line Numbers
  1. <%  
  2.        i=0;
  3.        while(i<4) {
  4. %>
  5.   <table align="left" width="100%">
  6.    <tr>
  7.         <td>
  8.          <%
  9.     out.print("SNo. " + (i + 1));            
  10.         %>
  11.             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                     
  12.          <input type="submit" name="name" value="Click">
  13.         </td>        
  14.     </tr>
  15.     <tr>
  16.        <td> 
  17.         <% 
  18.                out.print("ABC");
  19.          %> 
  20.        </td>
  21.      </tr>
  22.   </table>
  23. <%   
  24.        }
  25. %>
  26.  
My problem is -- when any one of the 4 buttons was clicked how can I find which button was clicked, so that I can get the SNo associated with it.

Is there any way to find the button which is clicked?

Thanks in advance,
Tiijnar
Dec 11 '08 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
You have 4 buttons each with the same name "name" and same value "Click". Use that index i to name your buttons and values as well.
Dec 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.