Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di ubbicom
    Registrato dal
    Mar 2004
    Messaggi
    1,407

    Problema con form ed evento onChange in pagina ASP

    ciao.

    ho un problema con un form nel quale è prevista una select del tipo :

    codice:
    <select size="1" name="nome" onChange="window.location='index.asp?dip='+this.options[this.selectedIndex].value;">
    Perchè quando parte l'evento onchange dalla select la pagina index.asp viene ricaricata sul browser e tutti i dati inseriti nel form prima della select vengono perduti.

    Come si risolve?
    grazie

  2. #2
    Utente di HTML.it L'avatar di ubbicom
    Registrato dal
    Mar 2004
    Messaggi
    1,407
    Ho scritto così, ma il valore seelzionato nella prima select centro si perde quando si attiva l'evento onchange della seconda select tipo.

    codice:
    <%
    
    Function SELECTED(firstVal, secondVal)
    If cSTR(firstVal) = cSTR(secondVal) then
       SELECTED = " SELECTED"
    End If
    End Function
    
        SQL = "SELECT * FROM ... "
        
        Set rec = Server.CreateObject("ADODB.Recordset")
        rec.Open sql, cn
        
        if not rec.eof then
    
    %>
    
    	<select size="1" name="Centro" class="ctrl">
                <option value="">Seleziona</option>
          
    
    <%  
        rec.MoveFirst()
        Do While Not rec.EOF
    %>
    
    <% if request.querystring("Centro") <> "" then %>
    
    <option value="<%=Centro%>"<%=SELECTED(Centro, request.querystring("Centro"))%>>
    <%=Centro%></option>
    
    <% else%>
    
    <option value="<%=rec("Centro")%><%=rec("Centro")%></option>
    
    <% end if %>
    
    <%
    
        rec.MoveNext()
        Loop
        end if       
        
        rec.Close()
        set rec = Nothing
    
    %>
                			
                </select>
    
    
    <%
    
        SQL = "SELECT * FROM... "
    
        Set rec = Server.CreateObject("ADODB.Recordset")
        rec.Open sql, cn
        
        if not rec.eof then
    
    %>
    
    <select size="1" name="tipo" class="ctrl" onChange="window.location='index.asp?Centro=<%=Centro%>&tipo='+this.options[this.selectedIndex].value;">
                    <option>Seleziona</option>
    
                    
    <%  
        rec.MoveFirst()
        Do While Not rec.EOF
    %>
    
    
    <option value="<%=rec("TIPO")%>"<%=SELECTED(rec("TIPO"), request.querystring("tipo"))%>>
    <%=rec("TIPO")%></option>
    
    <%
        rec.MoveNext()
        Loop
        end if       
        
        rec.Close()
        set rec = Nothing
    
    %>
                    
    
                  </select>

  3. #3
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Nella prima select non c'è l'onchange quindi quando la seconda ricarica la pagina non trova alcun valore...

    Roby

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 © 2026 vBulletin Solutions, Inc. All rights reserved.