-
Ragazzi,
ho bisogno di creare una form, e tramite javascript voglio che al cambiare del radio button che ho spuntato cambi l'indirizzo di OK.Ecco di seguito il codice:
<script type="text/javascript"> <!-- function okURL (theForm){ if (theForm.$$video1$$[0].checked) theForm.okURL.value = "cisco.com/web/IT/events/video_datasheet/video_uc500.html"; if (theForm.$$video1$$[1].checked) theForm.okURL.value = "//cisco.com/web/IT/events/video_datasheet/video_asa5500.html"; } function Controllo(theForm) { alert (document.form1.okURL.value) if (theForm.$$nome$$.value == "") { alert ("Per favore, introduci il campo NOME."); theForm.$$nome$$.focus(); return (false); } if (theForm.$$cognome$$.value == "") { alert ("Per favore, introduci il campo COGNOME."); theForm.$$cognome$$.focus(); return (false); } if (theForm.$$ragione_sociale$$.value == "") { alert ("Per favore, introduci il campo RAGIONE SOCIALE."); theForm.$$ragione_sociale$$.focus(); return (false); } if (theForm.$$citta$$.value == "") { alert ("Per favore, introduci il campo CITTA'."); theForm.$$citta$$.focus(); return (false); } if (theForm.$$provincia$$.value == "") { alert ("Per favore, introduci il campo PROVINCIA'."); theForm.$$provincia$$.focus(); return (false); } if (theForm.$$indirizzo$$.value == "") { alert ("Per favore, introduci il campo INDIRIZZO'."); theForm.$$indirizzo$$.focus(); return (false); } if (theForm.$$to$$.value == "") { alert ("Per favore, introduci il campo E-MAIL."); theForm.$$to$$.focus(); return (false); } theForm.to.value=theForm.$$to$$.value; if (theForm.$$telefono$$.value == "") { alert ("Per favore, introduci il campo TELEFONO'."); theForm.$$telefono$$.focus(); return (false); } } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body> <form name="form1" onsubmit="return Controllo(this)" method="post" action="scip. retesesa.it:81/deliverMail.asp" > <input name="from" type="hidden" id="from" value="[email protected]" /> <input name="bcc" type="hidden" id="bcc" value="[email protected]" /> <input name="subject" type="hidden" id="subject" value="Iscrizione Computer Var-Cisco (Video Datasheet)" /> <input name="contentType" type="hidden" id="contentType" value="html" /> <input name="bodyForm" type="hidden" id="bodyForm" value="cvar/conferma_cisco-datasheet.htm" /> <input name="okURL" type="hidden" id="okURL" value=" cisco.com/web/IT/events/video_datasheet/video_uc500.html" /> <input name="koURL" type="hidden" id="koURL" value=" computervar.it/webinar_cisco/form_cisco_datasheet.htm" /> <p>nome</p><input type="text" name="$$nome$$" size="20" /> <p>cognome</p><input name="$$cognome$$" type="text" id="$$cognome$$" size="20" /> <p>rag. sociale</p><input name="$$ragione_sociale$$" type="text" id="$$ragione_sociale$$" size="20" /> <p>indirizzo</p><input name="$$indirizzo$$" type="text" id="$$indirizzo$$" size="20" /> <p>città</p> <input name="$$citta$$" type="text" id="$$citta$$" size="20" /> <p>provincia</p><input name="$$provincia$$" type="text" id="$$provincia$$" size="10" /> <p>cap</p><input name="$$cap$$" type="text" id="$$cap$$" size="12" /> <p>email</p><input name="$$to$$" id="$$to$$" type="text" size="20" /> <input name="to" id="to" type="hidden" value="" /> <p>telefono</p><input name="$$telefono$$" type="text" id="$$telefono$$" size="15" /> <p>uc500</p><input name="$$video1$$" type="radio" id="$$video1$$3" value="Unified Communications 500" checked="checked" /> <p>asa5500</p><input name="$$video1$$" type="radio" id="$$video2$$" value="ASA 5500" /> <input type="submit" value="Registrati" name="B12" /> </form>Dove sta l'errore?? In pratica non riesco a cambiare l'indirizzo di okURL al variare dell'opzione spuntata.
Grazie a tutti.
-
La tua pagina generata da dreamweaver e' un po' sporca e di difficile approccio per chi vuole darti una mano: proverei a semplificarla un po', cosi' da permettere una lettura piu' semplice.
Per cio' che vuoi fare cmq basta qualcosa di questo tipo
<html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Valore 1 Valore 2 Valore 3</title> <style type="text/css"> label { display: block; } </style> <script type="text/javascript"> function setValue(currRadio){ document.forms[0].testo.value = currRadio.value } </script> </head> <body> <div> <form> <fieldset><legend>Scelta Valori</legend> <label>Valore 1 <input name="valori" onclick="setValue(this)" type="radio" value="1" /> </label> <label>Valore 2 <input name="valori" onclick="setValue(this)" type="radio" value="2" /> </label> <label>Valore 3 <input name="valori" onclick="setValue(this)" type="radio" value="3" /> </label> <label>Valore Selezionato <input name="testo" readonly="readonly" type="text" value="Nessuno" /> </label> </fieldset> </form> </div> </body> </html>Il doctype e' strict... l'ho rimosso perche' non sono premium : )
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi