Ciao a tutti,
Ho un menu a tendina ed un pulsante inseriti in un form, vorrei che schiacciando il tasto "enter" dopo aver fatto la scelta, mi invii il modulo senza bisogno di premere per forza il pulsante, come posso fare??
Grazie mille!!!
Ciao a tutti,
Ho un menu a tendina ed un pulsante inseriti in un form, vorrei che schiacciando il tasto "enter" dopo aver fatto la scelta, mi invii il modulo senza bisogno di premere per forza il pulsante, come posso fare??
Grazie mille!!!
Semplice:
nella SELECT:
onChange="document.nomedellaform.submit();"
Ciao!
"Le uniche cose che sbagli sono quelle che non provi a fare."
Atipica
Posta il codice!
"Le uniche cose che sbagli sono quelle che non provi a fare."
Atipica
<form name="modulo" method="post" onSubmit="Controllo()">
<select name="lista" onChange="document.modulo.submit();">
<option value="brusson" <%if loc="brusson" then%> selected <%end if%>>Brusson</option>
<option value="gaby" <%if loc="gaby" then%> selected <%end if%>>Gaby</option>
<option value="valgrisenche" <%if loc="valgrisenche" then%> selected <%end if%>>Valgrisenche</option>
<option value="rhemes" <%if loc="rhemes" then%> selected <%end if%>>Rhemes
Notre Dame</option>
<option value="pila" <%if loc="pila" then%> selected <%end if%>>Pila</option>
<option value="champorcher" <%if loc="champorcher" then%> selected <%end if%>>Champorcher</option>
</select>
<input name="Button" type="submit" value="Vai">
</form>
E la funzione Controllo che cosa fa?
Forse è meglio se posti anche quella...
"Le uniche cose che sbagli sono quelle che non provi a fare."
Atipica
<form name="modulo" method="post" onSubmit="return Controllo()">
<select name="lista" onChange="document.modulo.submit();">
<option value="brusson" <%if loc="brusson" then%> selected <%end if%>>Brusson</option>
<option value="gaby" <%if loc="gaby" then%> selected <%end if%>>Gaby</option>
<option value="valgrisenche" <%if loc="valgrisenche" then%> selected <%end if%>>Valgrisenche</option>
<option value="rhemes" <%if loc="rhemes" then%> selected <%end if%>>Rhemes
Notre Dame</option>
<option value="pila" <%if loc="pila" then%> selected <%end if%>>Pila</option>
<option value="champorcher" <%if loc="champorcher" then%> selected <%end if%>>Champorcher</option>
</select>
<input name="Button" type="submit" value="Vai">
</form>
N.B. il tasto invio in un form funziona esattamente come hai detto tu... invia il form... senza bisogno di cliccare sul bottone submit e senza bisogno di nessun JS!
Aggiungo inoltre che lo invia... sempre che la funzione Controllo() lo permetta
«Se leggi dimentichi, se vedi capisci, se fai impari» Piaget
ecco la funzione controllo:
function Controllo(){
var lista = document.modulo.lista.value;
if ((lista == "") || (lista == "undefined")) {
alert("la scelta della località è obbligatoria!");
document.modulo.lista.focus();
return false;
}
else {
var localita=document.modulo.lista.value;
document.modulo.action = "default_i.asp?loc="+localita;
document.modulo.submit();
}
}
prova una cosa di questo genere
<script>
function Controllo(){
var lista = document.modulo.lista.value;
if ((lista == "") || (lista == "undefined")) {
alert("la scelta della località è obbligatoria!");
document.modulo.lista.focus();
return false;
}
else {
var localita=document.modulo.lista.value;
document.modulo.action = "default_i.asp?loc="+localita;
return true
}
}
</script>
<form name="modulo" method="post" onSubmit="return Controllo()">
<select name="lista" onChange="document.modulo.submit();">
<option value="brusson" <%if loc="brusson" then%> selected <%end if%>>Brusson</option>
<option value="gaby" <%if loc="gaby" then%> selected <%end if%>>Gaby</option>
<option value="valgrisenche" <%if loc="valgrisenche" then%> selected <%end if%>>Valgrisenche</option>
<option value="rhemes" <%if loc="rhemes" then%> selected <%end if%>>Rhemes
Notre Dame</option>
<option value="pila" <%if loc="pila" then%> selected <%end if%>>Pila</option>
<option value="champorcher" <%if loc="champorcher" then%> selected <%end if%>>Champorcher</option>
</select>
<input name="Button" type="submit" value="Vai">
</form>
niente da fare, non mi funziona il tasto invio!! non mi da nessun segnale, come se non premessi niente!!