Visualizzazione dei risultati da 1 a 9 su 9

Discussione: controllo invio form

  1. #1

    controllo invio form

    mi fornite un banale esempio per la controllare l'invio di un form con asp
    Posso fare tutto in unica pagina?

  2. #2
    Cosa intendi per controllare l'invio di una form?

  3. #3
    ho due campi data da controllare, vorrei fare comparire ad esempio un segno di spunta rosso, se il campo non è correttamente compilato...

  4. #4
    codice:
    <%
    submit = request.serverVariables("REQUEST_METHOD") = "POST"
    thisPage = request.serverVariables("PATH_INFO")
    
    if submit then
    
      errore = false
    
      data1 = request.form("data1")
      data2 = request.form("data2")
    
        if not isDate(data1) then
        errore = true
        data1error = true
        end if
    
        if not isDate(data2) then
        errore = true
        data2error = true
        end if
    
       if not errore then
       ' qui fai le operazioni qualora le date sono corrette...
       end if
    
    end if
    %>
    <form method="post" action="<%=thisPage%>">
    Data 1 <input type="text" name="data1" value="<%=data1%>" /><% if data1error then %> <font color="red">V</font><% end if %>
    
    Data 2 <input type="text" name="data2" value="<%=data2%>" /><% if data2error then %> <font color="red">V</font><% end if %>
    
    <input type="submit" value="VAI" />
    </form>

  5. #5

  6. #6
    scusami ma nel caso in cui il form sia stato compilato in maniera corretta, come faccio ad inviare il form?

  7. #7
    La form viene inviata, nel mio esempio, alla stessa pagina che la contiente.
    Se guardi il codice c'è un blocco del tipo:
    codice:
       if not errore then
       ' qui fai le operazioni qualora le date sono corrette...
       end if
    Dentro quel blocco fai le operazioni che devi fare con i dati presi dalla form.
    Se poi vuoi fare apparire un messaggio alla fine fai così:
    [code]
    codice:
    <%
    submit = request.serverVariables("REQUEST_METHOD") = "POST"
    thisPage = request.serverVariables("PATH_INFO")
    
    if submit then
    
      errore = false
    
      data1 = request.form("data1")
      data2 = request.form("data2")
    
        if not isDate(data1) then
        errore = true
        data1error = true
        end if
    
        if not isDate(data2) then
        errore = true
        data2error = true
        end if
    
       if not errore then
         ' qui fai le operazioni qualora le date sono corrette...
         outMessage = "Operazione eseguita"
         data1 = ""
         data2 = ""
       else
         outMessage = "Si sono verificati degli errori"
       end if
    
    end if
    %>
    <form method="post" action="<%=thisPage%>">
    Data 1 <input type="text" name="data1" value="<%=data1%>" /><% if data1error then %> <font color="red">V</font><% end if %>
    
    Data 2 <input type="text" name="data2" value="<%=data2%>" /><% if data2error then %> <font color="red">V</font><% end if %>
    
    <input type="submit" value="VAI" />
    </form>
    <%
    if submit then
    response.write outMessage
    end if
    %>

  8. #8
    si ma se voglio inviare la form ad una altra pagina? solo ovviamente se i dati sono corretti?

  9. #9
    codice:
    <html>
    <head><title></title>
    </head>
    <body>
    <%
    submit = request.serverVariables("REQUEST_METHOD") = "POST"
    thisPage = request.serverVariables("PATH_INFO")
    
    if submit then
    
      errore = false
    
      data1 = request.form("data1")
      data2 = request.form("data2")
    
        if not isDate(data1) then
        errore = true
        data1error = true
        end if
    
        if not isDate(data2) then
        errore = true
        data2error = true
        end if
    
       if not errore then
    %>
    <form name="form2" method="post" action="altrapagina.asp">
    <input type="hidden" name="data1" value="<%=data1%>" />
    <input type="hidden" name="data2" value="<%=data2%>" />
    </form>
    <script language="javascript" type="text/javascript">
    <!--
    document.form2.submit();
    //-->
    </script>
    <%     
       else
         outMessage = "Si sono verificati degli errori"
       end if
    
    end if
    %>
    <form name="form1" method="post" action="<%=thisPage%>">
    Data 1 <input type="text" name="data1" value="<%=data1%>" /><% if data1error then %> <font color="red">V</font><% end if %>
    
    Data 2 <input type="text" name="data2" value="<%=data2%>" /><% if data2error then %> <font color="red">V</font><% end if %>
    
    <input type="submit" value="VAI" />
    </form>
    <%
    if submit then
    response.write outMessage
    end if
    %>
    </body>
    </html>

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.