Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400

    Select dinamiche ed evento OnChange

    Ciao.

    Ho queste select dinamiche, ma non riesco a memorizzare il valore selezionato all'interno della select, cioè se seleziono un valore dalla prima select non riesco a conservarlo selezionato se scelgo un valore dalla seconda select, dove sbaglio?

    codice:
    ' PRIMA QUERY PER PRIMA SELECT SORT
       strSql = "SELECT COUNTRY_NAME FROM Foglio2 GROUP BY COUNTRY_NAME ORDER BY COUNTRY_NAME ASC"
       Set objRs = Server.CreateObject("ADODB.Recordset")
       objRs.Open strSql, Conn, 3, 3
    %>
    	
    	<select size="1" name="sort" onChange="window.document.location='pageasp?sort='+this.options[this.selectedIndex].value;">
        
        <% sort_sel = request.querystring("sort") %>
        <% if sort_sel <> "" then %>
        <option value="<%=sort_sel%>" selected="selected"><%=sort_sel%></option>
        <% else %>
        <option selected>Seleziona valore</option>
            
    <%
    end if
    
    If Not objRs.EOF Then
    Do While Not objRs.EOF
    %>
              <option value= "<% = Trim(objRs("COUNTRY_NAME")) %>"><%  = Trim(objRs("COUNTRY_NAME")) %></option>
    <%
    objRs.MoveNext
    Loop
    End If
    objRs.Close
    %>
    
        </select>
    
    <%
    ' SECONDA QUERY PER LA SELECT IP_FROM
       strSql = "SELECT IP_FROM FROM Foglio2 GROUP BY IP_FROM ORDER BY IP_FROM ASC"
       Set objRs = Server.CreateObject("ADODB.Recordset")
       objRs.Open strSql, Conn, 3, 3
    %>
    
    <select name=ip_from onChange="window.document.location='pag_imente.asp?ip_from='+this.options[this.selectedIndex].value;">
    
        <% ip_from_sel = request.querystring("ip_from") %>
        <% if ip_from_sel <> "" then %>
        <option value="<%=ip_from_sel%>" selected="selected"><%=ip_from_sel%></option>
        <% else %>
        <option selected>Seleziona valore</option> 
            
    <%
    end if
    
    If Not objRs.EOF Then
    Do While Not objRs.EOF
    %>
              <option value= "<% = Trim(objRs("IP_FROM")) %>"><%  = Trim(objRs("IP_FROM")) %></option>
    <%
    objRs.MoveNext
    Loop
    End If
    objRs.Close
    %>
    </select>
    
    <%
    ' TERZA QUERY PER LA SELECT IP_TO
       strSql = "SELECT IP_TO FROM Foglio2 GROUP BY IP_TO ORDER BY IP_TO ASC"
       Set objRs = Server.CreateObject("ADODB.Recordset")
       objRs.Open strSql, Conn, 3, 3
    %>
    
    <select name=ip_to onChange="window.document.location='pag_imente.asp?ip_to='+this.options[this.selectedIndex].value;">
        
        <% ip_to_sel = request.querystring("ip_to") %>
        <% if ip_to_sel <> "" then %>
        <option value="<%=ip_to_sel%>" selected="selected"><%=ip_to_sel%></option>    
        <% else %>
        <option selected>Seleziona valore</option>   
            
    <%
    end if
    
    If Not objRs.EOF Then
    Do While Not objRs.EOF
    %>
              <option value= "<% = Trim(objRs("IP_TO")) %>"><%  = Trim(objRs("IP_TO")) %></option>
    <%
    objRs.MoveNext
    Loop
    End If
    objRs.Close
    %>
    </select>

  2. #2
    sbagli che la seconda select all'onchange non fa un submit del form e quindi non puoi prendere il valore della prima select....

    tutte e due le select devono portarsi dietro i valori di entrambe...la prima select avrà il this.option[] per il suo valore e un valore statico per la seconda select, e la seconda select il viceversa


  3. #3
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    Non ho capito.

  4. #4
    codice:
    'prima select
    
    onChange="window.location.href='page.asp?valore_seconda_select=<%= valore_seconda_select %>&valore_prima_select='+this.options[this.selectedIndex].value;"
    
    
    'seconda select
    
    onChange="window.location.href='page.asp?valore_prima_select=<%= valore_prima_select %>&valore_seconda_select='+this.options[this.selectedIndex].value;"

  5. #5
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    Non funziona, nessuno dei valori della select rimane selezionato :

    codice:
    'PRIMA SELECT
    <select name="sort" onChange="window.document.location='page.asp?ip_from<%=ip_from%>&sort='+this.options[this.selectedIndex].value;">
    
    'SECONDA SELECT
    <select name=ip_from onChange="window.document.location='page.asp?sort=<%=sort%>&ip_from='+this.options[this.selectedIndex].value;">

  6. #6
    controlla che siano passati corretti e fai il cast dei vazlori quando confronti usando cstr o cint a seconda del tipo che stai confrontando

  7. #7
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    Nella barra degli idnirizzi visualizzo:

    codice:
    page.asp?sort_sel=BOLIVIA&ip_from=94585424
    Ma il valore della prima select quando seleziono 94585424 dalla seconda select si riporta su Seleziona valore....

  8. #8
    nella seconda mett

    codice:
    sort=<%=sort%>
    invece immagino sia

    codice:
    sort=<%=sort_sel%>

  9. #9
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    è lo stesso, non cambia nulla:


    codice:
    'prima select
    <select name="sort" onChange="window.document.location='page.asp?ip_from_sel=<%=ip_from_sel%>&sort='+this.options[this.selectedIndex].value;">
    
    'seconda select
    <select name=ip_from onChange="window.document.location='page.asp?sort_sel=<%=sort_sel%>&ip_from='+this.options[this.selectedIndex].value;">

  10. #10
    Utente di HTML.it L'avatar di wegawhite
    Registrato dal
    Aug 2004
    Messaggi
    1,400
    Risolto, grazie in rosso le modifiche:

    codice:
    ' PRIMA QUERY PER PRIMA SELECT SORT
       strSql = "SELECT COUNTRY_NAME FROM Foglio2 GROUP BY COUNTRY_NAME ORDER BY COUNTRY_NAME ASC"
       Set objRs = Server.CreateObject("ADODB.Recordset")
       objRs.Open strSql, Conn, 3, 3
    %>
    	
    	<select name="sort" onChange="window.document.location='page.asp?ip_from=<%=ip_from_sel%>&sort='+this.options[this.selectedIndex].value;">
        
        <% sort_sel = request.querystring("sort") %>
        <% if sort_sel <> "" then %>
        <option value="<%=sort_sel%>" selected="selected"><%=sort_sel%></option>
        <% else %>
        <option selected>Seleziona valore</option>
            
    <%
    end if
    
    If Not objRs.EOF Then
    Do While Not objRs.EOF
    %>
              <option value= "<% = Trim(objRs("COUNTRY_NAME")) %>"><%  = Trim(objRs("COUNTRY_NAME")) %></option>
    <%
    objRs.MoveNext
    Loop
    End If
    objRs.Close
    %>
    
        </select>
    
      
    <%
    ' SECONDA QUERY PER LA SELECT IP_FROM
       strSql = "SELECT IP_FROM FROM Foglio2 GROUP BY IP_FROM ORDER BY IP_FROM ASC"
       Set objRs = Server.CreateObject("ADODB.Recordset")
       objRs.Open strSql, Conn, 3, 3
    %>
    
    <select name=ip_from onChange="window.document.location='page.asp?sort=<%=sort_sel%>&ip_from='+this.options[this.selectedIndex].value;">
    
        <% ip_from_sel = request.querystring("ip_from") %>
        <% if ip_from_sel <> "" then %>
        <option value="<%=ip_from_sel%>" selected="selected"><%=ip_from_sel%></option>
        <% else %>
        <option selected>Seleziona valore</option> 
            
    <%
    end if
    
    If Not objRs.EOF Then
    Do While Not objRs.EOF
    %>
              <option value= "<% = Trim(objRs("IP_FROM")) %>"><%  = Trim(objRs("IP_FROM")) %></option>
    <%
    objRs.MoveNext
    Loop
    End If
    objRs.Close
    %>
    </select>
    
    <%
    ' TERZA QUERY PER LA SELECT IP_TO
       strSql = "SELECT IP_TO FROM Foglio2 GROUP BY IP_TO ORDER BY IP_TO ASC"
       Set objRs = Server.CreateObject("ADODB.Recordset")
       objRs.Open strSql, Conn, 3, 3
    %>
    
    <select name=ip_to onChange="window.document.location='page.asp?ip_from=<%=ip_from_sel%>&sort=<%=sort_sel%>&ip_to='+this.options[this.selectedIndex].value;">
        
        <% ip_to_sel = request.querystring("ip_to") %>
        <% if ip_to_sel <> "" then %>
        <option value="<%=ip_to_sel%>" selected="selected"><%=ip_to_sel%></option>    
        <% else %>
        <option selected>Seleziona valore</option>   
            
    <%
    end if
    
    If Not objRs.EOF Then
    Do While Not objRs.EOF
    %>
              <option value= "<% = Trim(objRs("IP_TO")) %>"><%  = Trim(objRs("IP_TO")) %></option>
    <%
    objRs.MoveNext
    Loop
    End If
    objRs.Close
    %>
    </select>

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.