Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 21
  1. #1
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870

    Gestione campo Si/No in asp

    Ho creato un dbase con una tbl nella quale uno dei campi è previsto come Si/No.

    Nel dbase se la casella di spunta è vuota in asp restituisce valore 'false', mentre se è riempita restituisce 'true'.

    Vorrei che in asp si vedesse la casella con il segno o meno di spunta, così come si vede in access... è possibile?

    grazie a tutti

  2. #2
    se il valore sul db è true allora nel tag del checkbox metti selected altrimenti non metti nulla...

    il controllo ti consiglio di farlo così:

    codice:
    if (objRec("Campo")>0) then
      'metti selected
    else
      'non metti nulla
    end if
    in questo modo il controllo non dipende dai valori in italiano o inglese...

  3. #3
    Se usi le checkbox però non va selected ma checked
    Il resto è corretto, oppure puoi usare le variabili boleane

    codice:
    if CBool(objRec("Campo")) = True then
      'è true
    else
      'è false
    end if

  4. #4
    ops hai ragione è che sto fondendo!

  5. #5
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870
    Grazie, ma probabilmente non ho capito bene, ho scritto così ma non cambia nulla :master:

    codice:
    <%
    Dim ConnDown
    Set ConnDown=Server.CreateObject("ADODB.Connection")
    ConnDown.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& server.MapPath(path&"N_CONF.mdb")
    Dim SQLDown,RECDown
    SQLDown="select * from n_conf order by REL_TEC_DEL asc"
    Set RECDown=ConnDown.Execute(SQLDown)
    
    Function ConvertiData(data)
        giorno = Mid(data, InStr(1, data, "/") + 1, InStrRev(data, "/") - InStr(1, data, "/") - 1)
        mese = Left(data, InStr(1, data, "/") - 1)
        anno = Right(data, Len(data) - InStrRev(data, "/"))
        ConvertiData = giorno & "/" & mese & "/" & anno
    End Function
    
    if RECDown.eof then
    response.write "Record non trovato"
    else
    While Not RECDown.EOF
    
    REL_TEC_DEL = ConvertiData(CStr(RECDown("REL_TEC_DEL")))
    
    if CBool(RECDown("Bonificato")) = True then
      'è true
    else
      'è false
    end if
    
    %>
    
    <td align="left" width="101"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=RECDown("BONIFICATO")%></td>

  6. #6
    prova a mettere dei response.write al posto delle righe commentate!

  7. #7
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870
    Originariamente inviato da Etilico
    prova a mettere dei response.write al posto delle righe commentate!
    scusa non capisco....

  8. #8
    codice:
    if CBool(RECDown("Bonificato")) = True then
      response.write("True")
    else
      response.write("False")
    end if
    metti così e vedi che succede!

  9. #9
    Utente di HTML.it L'avatar di fraude
    Registrato dal
    Feb 2004
    Messaggi
    2,870
    Originariamente inviato da Etilico
    codice:
    if CBool(RECDown("Bonificato")) = True then
      response.write("True")
    else
      response.write("False")
    end if
    metti così e vedi che succede!
    grazie ma stampa tutta una serie di 'false' in testa alla pagina:

    codice:
    <%
    Dim ConnDown
    Set ConnDown=Server.CreateObject("ADODB.Connection")
    ConnDown.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& server.MapPath(path&"N_CONF.mdb")
    Dim SQLDown,RECDown
    SQLDown="select * from n_conf order by REL_TEC_DEL asc"
    Set RECDown=ConnDown.Execute(SQLDown)
    
    Function ConvertiData(data)
        giorno = Mid(data, InStr(1, data, "/") + 1, InStrRev(data, "/") - InStr(1, data, "/") - 1)
        mese = Left(data, InStr(1, data, "/") - 1)
        anno = Right(data, Len(data) - InStrRev(data, "/"))
        ConvertiData = giorno & "/" & mese & "/" & anno
    End Function
    
    if RECDown.eof then
    response.write "Record non trovato"
    else
    While Not RECDown.EOF
    
    REL_TEC_DEL = ConvertiData(CStr(RECDown("REL_TEC_DEL")))
    
    if CBool(RECDown("Bonificato")) = True then
      response.write("True")
    else
      response.write("False")
    end if
    %>
    </TR>
     
    <td align="left" width="101"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=RECDown("BONIFICATO")%></td>
    </tr>
    
    <%
    RECDown.MoveNext
    WEnd
    end if
    RECDown.Close
    ConnDown.Close
    Set RECDown = Nothing
    Set ConnDown = Nothing
    %>

  10. #10
    perchè probabilmente lo script è messo in cima alla pagina e i campi sono tutti false all'interno del recordset...

    Metti solo questo code:

    codice:
    <%
    Dim ConnDown
    Set ConnDown=Server.CreateObject("ADODB.Connection")
    ConnDown.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& server.MapPath(path&"N_CONF.mdb")
    Dim SQLDown,RECDown
    SQLDown="select * from n_conf order by REL_TEC_DEL asc"
    Set RECDown=ConnDown.Execute(SQLDown)
    
    Function ConvertiData(data)
        giorno = Mid(data, InStr(1, data, "/") + 1, InStrRev(data, "/") - InStr(1, data, "/") - 1)
        mese = Left(data, InStr(1, data, "/") - 1)
        anno = Right(data, Len(data) - InStrRev(data, "/"))
        ConvertiData = giorno & "/" & mese & "/" & anno
    End Function
    
    if RECDown.eof then
    response.write "Record non trovato"
    else
    While Not RECDown.EOF
    %>
    poi qua in mezzo inserisci il code che crea la riga relativa al recordset che ti serve e al punto giusto metterai il code che ti ho postato prima...

    al posto di response.write metterai una cosa del genere:

    codice:
    if CBool(RECDown("Bonificato")) = True then
      response.write("<input type="checkbox" name="checkbox" value="checkbox"> checked")
    else
      response.write("<input type="checkbox" name="checkbox" value="checkbox">")
    end if
    mi sono spiegato? :quote:

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.