Pagina 1 di 5 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 44
  1. #1
    Utente di HTML.it L'avatar di bobonzo
    Registrato dal
    Jul 2000
    Messaggi
    495

    nome campo in script per invio email

    salve, ho dei campi costruiti dinamicamente con javascript.
    invio tramite POST tutti i campi a send.php

    il problema è che le var dei campi in questione sono vuote...cioè con quale nome posso inviare i campi javascript allo script php che invii la email?
    inoltre il numero di questi capi è variabile
    un array forse? ma come?
    grazie

    codice:
    	while (puntatore<=lung) {
    		if (string.charAt(puntatore) == "@") {
    			cont++;
    			document.write('<tr><td align="right">Titolo</td>');
    			puntatore++;
    			subpuntatore=puntatore;
    			while (string.charAt(puntatore) != "@") puntatore++;
    			document.write('<td align="right"><input type="text" name="Articolo'+cont+'" size="20"');
    			document.write('value="'+string.substring(subpuntatore, puntatore)+'" onFocus="this.blur()">');
    			puntatore++;
    			subpuntatore=puntatore;
    			while (string.charAt(puntatore) != "@") puntatore++;
    			prezzo=parseFloat(string.substring(subpuntatore, puntatore));
    			document.write('<input type="hidden" name="Prezzo'+cont+'" value="'+prezzo+'"></td>');
    			puntatore++;
    			subpuntatore=puntatore;
    			while ((string.charAt(puntatore) != "@") && (string.charAt(puntatore) != "#")) puntatore++;
    			quantit=parseInt(string.substring(subpuntatore, puntatore));
    			document.write('<td align="right">Quantità</td>');
    			document.write('<td align="right"><input type="text" name="Quant'+cont+'" size="5" ');
    			document.write('value="'+quantit+'" onChange="update(this.form)" maxlength="3"></td>');
    			totale+=parseInt(prezzo*quantit*100);
    			document.write('<td align="right">Totale</td>');
    			document.write('<td align="right">&euro;<input type="text" name="Totale'+cont+'" size="12" ');
    			document.write('value="'+punteggiatura(parseInt(prezzo*quantit*100))+'" style="text-align: right" onFocus="this.blur()"></td>');
    			puntatore--;
    			document.write('</tr>');
    			}
    		puntatore++;
    		}
    }

  2. #2
    hola bobonzo... quanto tempo

    Dimmi... è vero che non sei così fagiano da non aver usato $_POST con il register gobals disattivato?


    hum.. conoscendoti.. sì, sei così fagiano

    non $var ma $_POST['var'] (con php >4.2)

    Certo che se non postoi il codice di lettura piuttosto che il form (perchè generato da JS poi? :master: ).....




  3. #3
    Utente di HTML.it L'avatar di bobonzo
    Registrato dal
    Jul 2000
    Messaggi
    495
    per me sei un'apparizione...tanto sperata quanto desiderata...

    sono nella
    sto cercando di metter su un piccolo carrello e sto disgraziatamente usando javascript.
    in sostanza...quando clicco sul carrello relativo a prodotti presi da un db mysql creo un cookie con nome@prezzo@quantità (si aggiungono altri prodotti nello stesso cookie separandoli con #).

    Chiaramente anche il modulo finale di riepilogo è in javascript...legge il cookie e mi restituisce i campi, quantità e prezzo.
    codice:
    <script language="javascript">
    
    function punteggiatura(num) {
    	retval =""+num;
    	if (retval < 100) {
    							retval="0,"+retval;
    							 	while (retval.length < 10){ 
                            	retval =" "+retval 
    									}
    								}
    	if ((retval <= 99999) && (retval >= 100)) {
    								temp1 = retval.substring(0,retval.length-2);
    								temp2 = retval.substring(retval.length-2,retval.length+1);
                           		retval =temp1+","+temp2;
    								while (retval.length < 10){ 
                            	retval =" "+retval 
    									}
    								}
    	if(retval >= 100000) {
    								temp1 = retval.substring(0,retval.length-5);
    								temp2 = retval.substring(retval.length-5,retval.length-2);
    								temp3 = retval.substring(retval.length-2,retval.length+1);
    								retval=temp1+"."+temp2+","+temp3;
    								while (retval.length < 10){ 
                            	retval =" "+retval 
    									}
    								}
    return retval;
    }
    
    function update(form) {
    	var Prezzoup=0;
    	var Qt=0;
    	var Sub=0;
    	var SubTotale=0;
    	for (i=1; i<=cont; i++) {
    		Prezzoup=eval("form.Prezzo"+i+".value");
    		Qt=eval("form.Quant"+i+".value");
    		if (isNaN(Qt) || (Qt<0) || (Qt=="")) {Qt=1;
    		                eval("form.Quant"+i+".value=1");}
    		if (Qt>999) {Qt=999;
    					   eval("form.Quant"+i+".value=999");}
    		Sub=(parseInt(Prezzoup*100))*(parseInt(Qt));
    		SubTotale+=Sub;
    		eval("form.Totale"+i+".value=punteggiatura(Sub)");
    	}
    	var indice=form.Trasporti.selectedIndex;
    	Prezzoup=parseInt(form.Trasporti.options[indice].value)*100;
    	form.TotaleTrasporti.value=punteggiatura(Prezzoup);
    	SubTotale+=parseInt(Prezzoup);
    	form.TotaleFinale.value=punteggiatura(SubTotale);
    }
    
    function errore(campo) {
    alert("Il campo "+campo+" è vuoto");
    }
    
    function controllo(form) {
    var err=0;
    if (form.email.value=="") err="Email";
    if (form.nazione.value=="") err="Nazione";
    if (form.cap.value=="") err="CAP";
    if (form.provincia.value=="") err="Provincia";
    if (form.comune.value=="") err="Comune";
    if (form.indirizzo.value=="") err="Indirizzo";
    if (form.societa.value=="") err="Società";
    if (form.cognome.value=="") err="Cognome";
    if (form.nome.value=="") err="Nome";
    if (err==0) Ordine.submit();
    else errore(err);
    }
    
    document.write('<p align="center">Modulo d\'ordine</p>');
    
    
    var quantit=0;
    var prezzo=0;
    var totale=0;
    var cont=0;
    var stop=0;
    var string=document.cookie;
    var puntatore=string.lastIndexOf("Lampade=#");
    var lung=string.indexOf("##");
    if (puntatore == -1) {document.write('
    <center>Il carrello è vuoto</center>'); stop=1;}
    	else {
    	document.write('
    <center>Tutti i campi sono obbligatori.
    E\' possibile cambiare la quantità degli articoli.
    Per eliminare un articolo immettere il valore \"0\".</center>
    ')
    	document.write('<form method="post" name="Ordine" action="send_ord.php">');
    	document.write('<div align="center"> <center>');
    	document.write('<table class="ordina" width="600" bgcolor="#CEE7FF" border="0" cellpadding="5"> <tr>');
    	document.write('<td align="right">Nome</td>');
    	document.write('<td><input type="text" name="nome" size="20" tabindex="1"></td> </tr>');
    	document.write('<tr> <td align="right">Cognome</td>');
    	document.write('<td><input type="text" name="cognome" size="20" tabindex="2"></td></tr>');
    	document.write('<tr> <td align="right">Società</td>');
    	document.write('<td><input type="text" name="societa" size="20" tabindex="3"></td></tr>');
    	document.write('<tr><td align="right">Indirizzo</td>');
    	document.write('<td><input type="text" name="indirizzo" size="30" tabindex="4"></td></tr>');
    	document.write('<tr><td align="right">Comune e provincia</td>');
    	document.write('<td><input type="text" name="comune" size="20" tabindex="5"> <input type="text" name="provincia" size="4" tabindex="6" maxlength="2"></td></tr>');
    	document.write('<tr><td align="right">CAP</td>');
    	document.write('<td><input type="text" name="cap" size="7" tabindex="7" maxlength="5"></td></tr>');
    	document.write('<tr><td align="right">Nazione</td>');
    	document.write('<td><input type="text" name="nazione" size="20" tabindex="8"></td></tr>');
    	document.write('<tr><td align="right">E-mail</td>');
    	document.write('<td><input type="text" name="email" size="20" tabindex="9"></td></tr>');
    	document.write('</table></center></div>');
    	document.write('<div align="center"><center><table class="ordina" width="600" bgcolor="#CEE7FF" border="0" cellpadding="5">');
    	while (puntatore<=lung) {
    		if (string.charAt(puntatore) == "@") {
    			cont++;
    			document.write('<tr><td align="right">Titolo</td>');
    			puntatore++;
    			subpuntatore=puntatore;
    			while (string.charAt(puntatore) != "@") puntatore++;
    			document.write('<td align="right"><input type="text" name="Articolo'+cont+'" size="20"');
    			document.write('value="'+string.substring(subpuntatore, puntatore)+'" onFocus="this.blur()">');
    			puntatore++;
    			subpuntatore=puntatore;
    			while (string.charAt(puntatore) != "@") puntatore++;
    			prezzo=parseFloat(string.substring(subpuntatore, puntatore));
    			document.write('<input type="hidden" name="Prezzo'+cont+'" value="'+prezzo+'"></td>');
    			puntatore++;
    			subpuntatore=puntatore;
    			while ((string.charAt(puntatore) != "@") && (string.charAt(puntatore) != "#")) puntatore++;
    			quantit=parseInt(string.substring(subpuntatore, puntatore));
    			document.write('<td align="right">Quantità</td>');
    			document.write('<td align="right"><input type="text" name="Quant'+cont+'" size="5" ');
    			document.write('value="'+quantit+'" onChange="update(this.form)" maxlength="3"></td>');
    			totale+=parseInt(prezzo*quantit*100);
    			document.write('<td align="right">Totale</td>');
    			document.write('<td align="right">&euro;<input type="text" name="Totale'+cont+'" size="12" ');
    			document.write('value="'+punteggiatura(parseInt(prezzo*quantit*100))+'" style="text-align: right" onFocus="this.blur()"></td>');
    			puntatore--;
    			document.write('</tr>');
    			}
    		puntatore++;
    		}
    }
    totale+=1052; //prezzo delle spese di spedizione di default (10,52*100)
    if (stop != 1) {
    	document.write('<tr><td align="right">Spedizione</td>');
    	document.write('<td align="right"><select size="1" name="Trasporti" onChange="update(this.form)">');
    	document.write('<option selected value="10,52">Italia</option>');
    	document.write('<option value="20,41">Europa</option>');
    	document.write('<option value="30,85">Asia</option>');
    	document.write('<option value="54,23">America</option>');
    	document.write('</select></td><td colspan="2" align="right"></td>');
    	document.write('<td align="right">Totale</td>');
    	document.write('<td align="right">&euro;<input type="text" name="TotaleTrasporti" size="12" value="'+punteggiatura(1052)+'" style="text-align: right" onFocus="this.blur()"></td>');
    	document.write('</tr><tr><td colspan="4" align="right"></td>');
    	document.write('<td align="right">Totale</td>');
    	document.write('<td align="right">&euro;<input type="text" name="TotaleFinale" size="12" value="'+punteggiatura(totale)+'" style="text-align: right" onFocus="this.blur()"></td>');
    	document.write('</tr></table></center></div>');
    	document.write('<p align="center"><input type="button" value="Invia" name="B1" tabindex="10" onClick="controllo(this.form)">');
    	document.write('<input type="reset" value="Reimposta" name="B2" tabindex=11"></p>');
    }
    	
    document.write('</form>');
    
    </script>
    Adesso invio il tutto con POST a send.php (non sono così fagiano come credi..avevo usato il post ma lavoro in locale con easyphp e non so perchè ma non va)
    Codice PHP:
    <?php

    // L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
    $to "webmaster@progedit.com";

    //errori
    $back "<font class='estratto'>[url='javascript:history.go(-1);']Torna indietro[/url]</font>";
    $errore "<center>



    <font class='breve'>Si sono verificati i seguenti errori:</font>\n</center>"
    ;

    //semplifico le var
    $nomex trim(stripslashes($_POST['nome']));
    $cognomex trim(stripslashes($_POST['cognome']));
    $societax trim(stripslashes($_POST['societa']));
    $indirizzox trim(stripslashes($_POST["indirizzo"]));
    $comunex trim(stripslashes($_POST["comune"]));
    $provinciax trim(stripslashes($_POST["provincia"]));
    $capx trim(stripslashes($_POST["cap"]));
    $nazionex trim(stripslashes($_POST["nazione"]));
    $emailx trim(stripslashes($_POST["email"]));
    $articolox trim(stripslashes($_POST["Articolo"]));
    $prezzox trim(stripslashes($_POST["Prezzo"]));
    $quantx trim(stripslashes($_POST["Quant"]));


    // IL SOGGETTO DELLA MAIL
    $subject "Ordine: ";

    // COSTRUIAMO IL CORPO DEL MESSAGGIO
    $body "Ecco il messaggio inviato dal visitatore:\n\n";
    $body .= "Nome: " $nomex "\n";
    $body .= "Cognome: " $cognomex "\n\n";
    $body .= "Società: " $societax "\n\n";
    $body .= "Indirizzo " $indirizzox "\n";
    $body .= "Comune " $comunex "\n";
    $body .= "provincia " $provinciax "\n";
    $body .= "CAP " $capx "\n";
    $body .= "Nazione " $nazionex "\n";
    $body .= "Email " $emailx "\n";
    $body .= "Articolo " $articolox "\n";
    $body .= "Prezzo " $prezzox "\n";
    $body .= "Quantità " $quantx "\n";

    // INTESTAZIONI SUPPLEMENTARI
    $headers "From: Modulo utenti<modulo@progedit.com>";

    if (
    $nomex == '') {
    $errore .= "<center>
    <font class='breve'>Hai dimenticato di inserire il tuo nome</font>


    $back</center>";
    echo 
    $errore;
    die();
    }


    //controllo sul campo email 
    if(ereg(".+\@.+\..+"$emailx) && (ereg("^[a-zA-Z0-9_@.-]+$"$emailx)) && ($emailx != '')) {

    // INVIO DELLA MAIL
    if(@mail($to$subject$body$headers)) { // SE L'INOLTRO E' ANDATO A BUON FINE...

    echo "<center>



    <font class='breve'>La mail è stata inviata con successo
    La nostra redazione ti risponderà al più presto
    Grazie</font>

    $back</center>";

    } else {
    // ALTRIMENTI...

    echo "<center>



    <font class='breve'>Si sono verificati dei problemi nell'invio della mail</font>


    $back</center>";

    }
    }
    else { echo 
    "<center>



    <font class='breve'>Inserisci una email corretta</font>


    $back</center>"; }
    ?>

  4. #4
    Utente di HTML.it L'avatar di bobonzo
    Registrato dal
    Jul 2000
    Messaggi
    495
    se potessi/sapessi usare bene php e mysql userei le sessioni ma l'idea mi spaventa....senza nessuno che mi dia una mano la vedo dura e js mi sembrava una scorciatoia...

    [nella pagina del carrello, dove sostanzialmente lo script legge il cookie e stampa la tabella avrei voluto recuperare anche altri dati dei prodotti (collegandomi al db) ma non so come integrare php e document.write.

    così facendo potrei inserire nel cookie $id, $prezzo, $quantità e recuperare i dati dal db tramite una query.
    ma come posso intercalare una query in:
    carrello.htm
    codice:
    <script language="javascript">
    function cancella() {
    document.cookie = "Lampade=0";
    location.href="carrello.htm";
    }
    function deleteart(nomearticolo) {
    var deletearticle=0;
    var sostflag=0;
    var subpuntatore=0;
    var string=document.cookie;
    var puntatore=string.lastIndexOf("Lampade=#");
    var lung=string.indexOf("##");
    var newstring="Lampade=#";
    	while (puntatore<=lung) {
        		deletearticle=0;
    		if (string.charAt(puntatore) == "@") {
    			puntatore++;
    			subpuntatore=puntatore;
    			while (string.charAt(puntatore) != "@") puntatore++;
    			if (string.substring(subpuntatore, puntatore) == nomearticolo) deletearticle=1;
    			if (deletearticle==0) newstring+="@"+string.substring(subpuntatore, puntatore);
    			puntatore++;
    			subpuntatore=puntatore;
    			while (string.charAt(puntatore) != "@") puntatore++;
    			if (deletearticle==0) newstring+="@"+string.substring(subpuntatore, puntatore);
    			puntatore++;
    			subpuntatore=puntatore;
    			while ((string.charAt(puntatore) != "@") && (string.charAt(puntatore) != "#"))puntatore++;
    			if (deletearticle==0) newstring+="@"+string.substring(subpuntatore, puntatore);
    			puntatore--;
    			}
    		puntatore++;
    		}
    newstring+="##";
    
    puntatore=newstring.lastIndexOf("@");
    if (puntatore != -1) document.cookie=newstring;
    else document.cookie = "Lampade=0";
    location.href="carrello.htm";	
    
    }
    
    function chiudi() {
    close();
    }
    
    function punteggiatura(num) {
    	retval =""+num;
    	if (retval < 100) {
    							retval="0,"+retval;
    							 	while (retval.length < 10){ 
                            	retval =" "+retval 
    									}
    								}
    	if ((retval <= 99999) && (retval >= 100)) {
    								temp1 = retval.substring(0,retval.length-2);
    								temp2 = retval.substring(retval.length-2,retval.length+1);
                           		retval =temp1+","+temp2;
    								while (retval.length < 10){ 
                            	retval =" "+retval 
    									}
    								}
    	if(retval >= 100000) {
    								temp1 = retval.substring(0,retval.length-5);
    								temp2 = retval.substring(retval.length-5,retval.length-2);
    								temp3 = retval.substring(retval.length-2,retval.length+1);
    								retval=temp1+"."+temp2+","+temp3;
    								while (retval.length < 10){ 
                            	retval =" "+retval 
    									}
    								}
    return retval;
    }
    
    document.write('<div align="center"> <center>');
    document.write("
    
    
    ");
    var quant=0;
    var prezzo=0;
    var totale=0;
    var string=document.cookie;
    var puntatore=string.lastIndexOf("Lampade=#");
    var lung=string.indexOf("##");
    if (puntatore == -1) document.write('
    Il carrello è vuoto');
    	else {
    	document.write('<table width="600" border="0" cellpadding="5" cellspacing="0">');
    	document.write('<tr bgcolor="#eeeeee"><td><font class="subtitlib">Titolo</font></td>');
    	document.write('<td align="right"><font class="subtitlib">Prezzo</font></td>');
    	document.write('<td align="right"><font class="subtitlib">Quantità</font></td>');
    	document.write('<td align="right"><font class="subtitlib">Totale</font></td>');
    	document.write('<td align="right"></td></tr><tr></tr>');
    	while (puntatore<=lung) {
    		if (string.charAt(puntatore) == "@") {
    			document.write('<tr bgcolor="#CEE7FF">');
    			puntatore++;
    			subpuntatore=puntatore;
    			while (string.charAt(puntatore) != "@") puntatore++;
    			nomearticolo=string.substring(subpuntatore, puntatore);
    			document.write('<td align="left"><font class="txtaut"> '+string.substring(subpuntatore, puntatore)+'</font></td>');
    			puntatore++;
    			subpuntatore=puntatore;
    			while (string.charAt(puntatore) != "@") puntatore++;
    			prezzo=parseFloat(string.substring(subpuntatore, puntatore));
    			document.write('<td align="right"><font class="txtaut">&euro;'+punteggiatura(parseInt(prezzo*100))+'</font></td>');
    			puntatore++;
    			subpuntatore=puntatore;
    			while ((string.charAt(puntatore) != "@") && (string.charAt(puntatore) != "#")) puntatore++;
    			quant=parseInt(string.substring(subpuntatore, puntatore));
    			document.write('<td align="right"><font class="txtaut">'+quant+'</font></td>');
    			totale+=parseInt(prezzo*quant*100);
    			document.write('<td align="right"><font class="txtaut">&euro;'+punteggiatura(parseInt(prezzo*quant*100))+'</font></td>');
    			document.write('<td align="right"><font class="txtaut">[img]del.gif[/img]</font></td>');
    			puntatore--;
    			document.write('</tr>');
    			}
    		puntatore++;
    		}
    	document.write('<tr></tr><tr bgcolor="#CEE7FF">');
    	document.write('<td colspan="3" align="right"></td>');
    	document.write('<td align="right"><font class="subtitlib">Totale: &euro;'+punteggiatura(totale)+'</font></td><td></td>');
    	document.write('</tr> </table> </center> </div>');
    document.write('<div align="center">
    [img]ordina.gif[/img][img]svuota.gif[/img]</div>');
    	}
    
    </script>
    ti prego dammi una mano..

  5. #5
    ma è infinitamente più semplice e professionale con php!!!!!

    non ci vuole nulla!

    Il carrello on deve nemmeno andare nel db (salvo tue sclete particolari)...

    quanto al problema.. uno è sicuramente easyphp.. :faccinachevomita:

    l'altro può dipendere anche da easyphp.. cioè dlala versione di php che ti ha installato...

    quanto vecchia è?



  6. #6
    Utente di HTML.it L'avatar di bobonzo
    Registrato dal
    Jul 2000
    Messaggi
    495
    l'ultima...

    so che per te è infinitamente semplice ...vorrei davvero fare tutto in php...ma da solo non ce la farei

  7. #7
    Utente di HTML.it L'avatar di bobonzo
    Registrato dal
    Jul 2000
    Messaggi
    495
    non è che mi metteresti sulla giusta via per fare qualcosa in php...?

  8. #8
    Originariamente inviato da bobonzo
    non è che mi metteresti sulla giusta via per fare qualcosa in php...?
    form e sessioni.. fine

    non posso fartelo io gratis il lavoro

    ma con le sessioni si riduce tutto ad avere una variabile che rappresenta il carrello (un array pieno di prodotti e relative quantità)...

  9. #9
    Utente di HTML.it L'avatar di bobonzo
    Registrato dal
    Jul 2000
    Messaggi
    495
    mamma mia come sei amaro...non ti ricordavo così
    il lavoro è per un'azienda di famiglia dunque non ci cavo un ragno da un buco fidati

  10. #10
    Originariamente inviato da bobonzo
    mamma mia come sei amaro...non ti ricordavo così
    il lavoro è per un'azienda di famiglia dunque non ci cavo un ragno da un buco fidati
    ciò nontoglie che non posso sobbarcarmi le tue ore di lavoro

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.