salve,
ho una pagina jsp che contiene una select: È possibile richiamare un'azione cliccando sull'elemento scelto passandogli i dati dell'elemento? Se si, mi potete suggerire come?
grazie.
Gli esempi che ho trovato in rete richiamano l'azione, ma senza passare i dati dell'elemento scelto.
Questa è la pagia jsp in questione: funziona, però dopo aver selezionato l'elemento devo cliccare sul pulsante di submit, ed è quello che vorrei evitare.
codice:<%-- Document : SaveParam Created on : 16-set-2013, 11.29.14 Author : danilo --%> <%@ page language="java" %> <%@page contentType="text/html" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!--title></title--> <link rel="stylesheet" type="text/css" href="style2.css"> </head> <body> <SCRIPT LANGUAGE="JavaScript"> function aggiornaCampo(ff, sel) { var f = document.frm; var val = eval('f.' + sel.name + '_value'); if (val) { val.value = sel.options[sel.selectedIndex].value; } } </script> <%!int ixv = 0;%> <%!int iV = 0;%> <%!String Dati;%> <% String sel1 = ""; %> <jsp:useBean id="eGana" scope="session" class="gana.WElencoGana"/> <% eGana.esegui(); eGana.fine(); iV = eGana.getlenght(); if(iV>1){ %> <FORM name="frm" METHOD="post" ACTION="cercaGana.jsp" > <TABLE> <TR> <TD rowspan=500> <SELECT name="sel1" id="sel1" onchange="aggiornaCampo(this.form, this)" size="35" > <option> "scegli" <% for (ixv = 0; ixv < iV; ixv++) { %> <option> <%=eGana.getDati(ixv, 0)%>; <%=eGana.getDati(ixv, 1)%> <% } %> </select> </td> </TR> </TABLE> <INPUT type="hidden" name="sel1_value" id="sel1_value"> <p></p> <INPUT TYPE=SUBMIT /> </FORM> <% }else{ if (iV > 0) { %> <FORM name=singolo METHOD=POST id="singolo" ACTION="cercaGana.jsp" /> <INPUT type="text" name="sel1_value" value="<%=eGana.getDati(0, 0)%>;<%=eGana.getDati(0, 1)%>;"> <INPUT TYPE=SUBMIT /> </FORM> <% }else{ %> NON ESISTE!" <% } } %> <FORM name=inizio METHOD=POST ACTION="nuovo.jsp" /> <INPUT TYPE=SUBMIT value="NUOVO"/> </FORM> </body> </html>

Rispondi quotando
