HI
This is the simple code
you seethere'a an for loop, so there are many submit buttons !
when i click a submit button on page how should i know which button it was
Thanks

<table>
   <jsp:useBean id="o" class="shopping.shop"/>
   <jsp:setProperty name="o" property="id" value="${userid}"/>
   <% String f[]=o.listshop();
   for(int i=0;i<f.length && f[i]!=null ;i+=3){%>
      <tr>
         <td> 
	<form action="cart.jsp" method="get">
	     <%out.println(f[i+1]); %><br>  
	     <%out.println(f[i+2]); %> $ <br>
	     <input type=submit value="delete">
   <%} %>
               </form>		
         </td>
      </tr>
</table>

Use "id" attribute in your button declaration

I believe you can use the name attribute as well. Also I think that you are closing the for loop at the wrong place. With your way it should have been after the <tr>

for(int i=0;i<f.length && f[i]!=null ;i+=3){%>
      <tr>
         <td> 
	<form action="cart.jsp" method="get">
	     <%out.println(f[i+1]); %><br>  
	     <%out.println(f[i+2]); %> $ <br>
	     <input type=submit value="delete" name="submit_<%= i%>">
          </form>		
         </td>
      </tr>
<%} %>

And in a servlet you can take all the parameters from the request and check whose name starts with "submit_":

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.html#getParameterNames()

Enumeration en = request.getParameterNames();

The String after the "_" will be something to help distinguish which element you want to delete

In the old days before HTML 4 name was used heavily, however since then they made name optional attribute and id standard. Therefore it is recommended to use id over name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.