Pagina 1 di 4 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 38
  1. #1

    Caricare dati in base a scelta Menu a tendina

    Ciao a tutti,

    ho una tabella relativa a degli istituti. Questi vengono selezionati e posti in un menu a tendina così:

    codice:
    <select name="SelIstituto" size="1">
    <%
    sql = "SELECT IdIstituto, IstitutoNome FROM Istituto"
    set rs = conn.execute(sql) ' conn è l'oggetto connessione...
    if not rs.eof then
    do until rs.eof
    %>
    <option value="<%=rs("IdIstituto")%>"><%=rs("IstitutoNome")></option> 
    <%
    rs.moveNext
    loop
    end if
    rs.close
    set rs = nothing
    %>   	
    </select>
    Ora vorrei che quando scelgo uno di questi istituti, nella stessa pagina , mi carichi i dati relativi a questo... via, telefono, ecc... dati che risiedono nella medesima tabella.

    Qualcuno mi può aiutare e suggerire il procedimento da adottare?

    Grazie

  2. #2
    codice:
    <form name="scelta" method="post" action="stessa_pagina.asp?scelta=si"> 
    <select name="SelIstituto" size="1">
    <%
    selIstituto = request.form("SelIstituto")
    scelta = request.querystring("scelta")
    
    if scelta = "si" then
       sql = "SELECT * FROM Istituto WHERE IdIstituto = " & SelIstituto
    else
       sql = "SELECT IdIstituto, IstitutoNome FROM Istituto"
    end if
    
    
    set rs = conn.execute(sql) ' conn è l'oggetto connessione...
    
    if not rs.eof then
       do until rs.eof
    %>
          <option value="<%=rs("IdIstituto")%>"><%=rs("IstitutoNome")></option> 
    <%
          rs.moveNext
       loop
    end if
    
    'QUI VISUALIZZI LE INFORMAZIONI DELLA SCELTA SELEZIONATA 
    
    rs.close
    set rs = nothing
    %>   	
    </select>
    </form>
    Provare paura per un qualcosa che ti possa capitare nel futuro non ti evita quell'evento,ti fa soltanto vivere un presente sbagliato!

  3. #3
    Ciao maximum, grazie della risposta.

    Ho provato e mi carica i nomi degli istituti (come prima) e poi mi restituisce questo errore:

    codice:
    ADODB.Field error '80020009' 
    
    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

  4. #4
    codice:
    <html>
    <head>
    <title>Prova scelta dinamica</title>
    </head>
    <body>
    <form name="scelta" method="post" action="stessa_pagina.asp?scelta=si"> 
    <select name="SelIstituto" size="1">
    <%
    selIstituto = request.form("SelIstituto")
    scelta = request.querystring("scelta")
    
    if scelta = "si" then
       sql = "SELECT * FROM Istituto WHERE IdIstituto = " & SelIstituto
    else
       sql = "SELECT IdIstituto, IstitutoNome FROM Istituto"
    end if
    
    
    set rs = conn.execute(sql) ' conn è l'oggetto connessione...
    
    if not rs.eof then
       do until rs.eof
    %>
          <option value="<%=rs("IdIstituto")%>" <% if rs("IdIstituto") = selIstituto %> selectet="selected"<% end if %>><%=rs("IstitutoNome")%></option> 
    <%
          rs.moveNext
       loop
    end if
    
    'QUI VISUALIZZI LE INFORMAZIONI DELLA SCELTA SELEZIONATA 
    
    rs.close
    set rs = nothing
    %>   	
    </select>
    <input type="submit" value="Scegli">
    </form>
    </body>
    </html>
    Provare paura per un qualcosa che ti possa capitare nel futuro non ti evita quell'evento,ti fa soltanto vivere un presente sbagliato!

  5. #5
    Mi da errore qui:

    codice:
    <option value="<%=rs("IdIstituto")%>" <% if rs("IdIstituto") = selIstituto %> selected="selected"<% end if %>><%=rs("IstitutoNome")%></option>
    codice:
    Expected 'Then' 
    
     
    
    if rs("IdIstituto") = selIstituto
    eh ok... se poi metto il Then siamo al punto di prima...

    codice:
    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

  6. #6
    codice:
    if qualcosa = qualcosaltro THEN

  7. #7
    Ehm si l'ho messo... vedi messaggio di prima...

  8. #8
    Fatti stampare la query:

    codice:
    <html>
    <head>
    <title>Prova scelta dinamica</title>
    </head>
    <body>
    <form name="scelta" method="post" action="stessa_pagina.asp?scelta=si"> 
    <select name="SelIstituto" size="1">
    <%
    selIstituto = request.form("SelIstituto")
    scelta = request.querystring("scelta")
    
    if scelta = "si" then
       sql = "SELECT * FROM Istituto WHERE IdIstituto = " & SelIstituto
    else
       sql = "SELECT IdIstituto, IstitutoNome FROM Istituto"
    end if
    
    response.write(sql)
    response.End() 
    
    set rs = conn.execute(sql) ' conn è l'oggetto connessione...
    
    if not rs.eof then 
       do until rs.eof
    %>
          <option value="<%=rs("IdIstituto")%>" <% if rs("IdIstituto") = selIstituto then %> selectet="selected"<% end if %>><%=rs("IstitutoNome")%></option> 
    <%
          rs.moveNext
       loop
    end if
    
    'QUI VISUALIZZI LE INFORMAZIONI DELLA SCELTA SELEZIONATA 
    
    rs.close
    set rs = nothing
    %>   	
    </select>
      <input name="submit" type="submit" value="Scegli">
    </form>
    </body>
    </html>
    Provare paura per un qualcosa che ti possa capitare nel futuro non ti evita quell'evento,ti fa soltanto vivere un presente sbagliato!

  9. #9
    Inserendo il:

    codice:
    response.write(sql)
    response.End()
    ora non mi da msg di errore solo che non mi seleziona alcun istituto nel menu a tendina. Però si blocca lì nel senso che i campi di testo che vengono dopo non me li visualizza.
    Cosa che faceva prima... dove però appunto mi dava il msg di errore.

  10. #10
    Ok, la posti la query che ti viene stampata?
    Provare paura per un qualcosa che ti possa capitare nel futuro non ti evita quell'evento,ti fa soltanto vivere un presente sbagliato!

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.