ho un carrello della spesa creato in questo modo:
al click del pulsante svuota dovrei svuotare il carrello,xò non so dove inserire le istruzioni java e come collegarle col pulsante,la funzione java dovrebbe essere qualkosa di simile:codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ page language="java" import="java.util.*" import="java.lang.*"%> <html> <head><title>'ListaCarrello.jsp'</title> <script type="text/javascript"> function AllaRicerca() { location.href = ("ricerca.jsp"); } </script> </head> <body> <h2 align="center">Il tuo carrello della spesa</h2> <% Hashtable articolo = (Hashtable)session.getAttribute("Prodotto"); if (request.getParameter("idProd") != null && request.getParameter("prod")!= ""){ String strQuant = request.getParameter("Quantità"); Integer app = null; int intQuant = app.parseInt(strQuant); String strId = request.getParameter("idProd"); Integer appoggio = null; int intId = appoggio.parseInt(strId); String strNome = request.getParameter("NomeProd"); String strDescr = request.getParameter("DescrProd"); String strPrezzo = request.getParameter("PrezzoProd"); Float appog = null; float fltPrezzo = appog.parseFloat(strPrezzo); String[] dati_prod= {strId, strNome, strPrezzo, strQuant}; articolo.put(intId, dati_prod); session.setAttribute("Prodotto", articolo); articolo=(Hashtable)session.getAttribute("Prodotto"); } //fine if String[] valori; Enumeration lista = articolo.elements(); %> <div align="center"> <table border=0 cellpadding=0 cellspacing=0> <% while (lista.hasMoreElements()){ valori = (String[])lista.nextElement(); %> <tr> <td width="100"> <%= valori[1] %> </td> <td width="100"> Euro <%=valori[2] %> </td> <td width="100"> Quantità: <%=valori[3] %> </td> </tr> <% } %> </table> <input type="button" value="Torna in Ricerca" onclick="AllaRicerca()"> <input type="button" value="Svuota carrello" name="B3"> </div> </body></html>
non so neanche se è possibile una cosa del genere,visto che articolo è di tipo Hashtablecodice:while (lista.hasMoreElements(){ Item item=(Item)lista.nextElement(); articolo.removeElement(item); }

Rispondi quotando
