Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2006
    Messaggi
    238

    Postback ed eventi: è questo il metodo corretto?

    Ciao

    Ho creato una pagina web
    in cui ho inserito 2 tag "input": oggetto e domanda.

    Poi ho inserito un button al cui click viene inviata una mail.

    codice:
    <form name="form1" method="post" action="contatti.php" id="form1">
    <div>
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTNAME" id="__EVENTNAME" value="" />
    </div>
    
    <script type="text/javascript">
    //<![CDATA[
    var theForm = document.forms['form1'];
    if (!theForm) {
        theForm = document.form1;
    }
    function __doPostBack(eventTarget, eventName) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTNAME.value = eventName;
            theForm.submit();
    
        }
    }
    
    //]]>
    
    </script>
    <table style="heigth:155px; width:400px;"><tr>
    <td><span >Oggetto</span></td>
    <td colspan="2"><input id="Oggetto" type="text"  /></td></tr>
    <tr><td><span class="GenericText_0">Domanda</span></td>
    <td><textarea id="Domanda" value="Domanda" ></textarea></td><td >
    <button id="Invia" type="button"  onclick="javascript:__doPostBack('Invia', 'onclick');">Invia</button></td></tr>
    </table>


    Da codice poi vado ad individuare l'evento con
    if($_POST["__EVENTTARGET"] == 'Invia' && $_POST["__EVENTNAME"] == 'onclick')
    {
    codice per inviare la mail

    }


    E' questo il modo corretto per effettuare il postback?

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2006
    Messaggi
    238
    up

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.