How to know which button is clicked in JSP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tiijnar
    New Member
    • Nov 2008
    • 14

    How to know which button is clicked in JSP

    Hi,

    I am using a JSP in my application. In JSP page I created tables and buttons inside a loop.
    Code:
    <%  
           i=0;
           while(i<4) {
    %>
      <table align="left" width="100%">
       <tr>
            <td>
             <%
    	out.print("SNo. " + (i + 1));			
            %>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 									
             <input type="submit" name="name" value="Click">
            </td>		
        </tr>
        <tr>
           <td> 
            <% 
                   out.print("ABC");
             %> 
           </td>
         </tr>
      </table>
    <%   
           }
    %>
    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
    Last edited by Nepomuk; Dec 11 '08, 06:11 PM. Reason: Please use [CODE] tags!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    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.

    Comment

    Working...