DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    s Guest

    CHECKBOX.CHECKED


    hi all.
    I want to retrieve my data from D.B.
    How can I check for a field that when some data was in it, the proper checkbox
    on the form is checked?

  2. #2
    Devin Knutson Guest

    Re: CHECKBOX.CHECKED

    "s" <s_mahd@yahoo.com> wrote in message news:3b692b0d@news.devx.com...
    >
    > hi all.
    > I want to retrieve my data from D.B.
    > How can I check for a field that when some data was in it, the proper

    checkbox
    > on the form is checked?


    You can read the value of whatever record you are on from inside the checkbox
    declaration, and determine whether to have it checked that way. Something
    like this:


    <INPUT TYPE="Checkbox" NAME="cb" VALUE="blammo" <%If rs("blammo") = "on" Then
    Response.Write("CHECKED")%>>

    HTH!

    --
    Devin
    http://www.mp3.com/DevinK
    _______________________________________________________
    Look on the bright side... After the next four years,
    we'll probably never have to deal with another Republican
    President in our lifetime.


  3. #3
    s Guest

    Re: CHECKBOX.CHECKED


    Dear Devin,
    Thank you so much.I used your code in my page but still have question:
    How can I traverse in records in table and based on a special value for a
    field,check the checkbox in form?
    This is the code:

    <body>

    <% Set conn = Server.CreateObject("adodb.connection")
    conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0 ; DATA SOURCE=d:\inetpub\wwwroot\checkbox_proj\tdb.mdb"
    sql = "SELECT * FROM t"
    Set rs = Server.CreateObject("adodb.recordset")
    rs.open sql,conn
    %>

    <% while not rs.eof %>
    <form method="POST" action="output.asp" webbot-action="--WEBBOT-SELF--">

    <input type="checkbox" name="C1" value="ON" <% if rs("cb")="on" then
    response.write("checked") end if %>>RD
    <input type="submit" value="Next" name="B3">
    </form>

    <%
    rs.movenext
    wend
    %>

    </body>
    when I use this code,the checkbox will be repeated in no. of records in d.b.
    Please help me
    s













    >You can read the value of whatever record you are on from inside the checkbox
    >declaration, and determine whether to have it checked that way. Something
    >like this:
    >
    >
    ><INPUT TYPE="Checkbox" NAME="cb" VALUE="blammo" <%If rs("blammo") = "on"

    Then
    >Response.Write("CHECKED")%>>
    >
    >HTH!
    >
    >--
    > Devin
    > http://www.mp3.com/DevinK
    > _______________________________________________________
    > Look on the bright side... After the next four years,
    > we'll probably never have to deal with another Republican
    > President in our lifetime.
    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links