How do you return a value in a checkbox?

Posted on 2004-10-21
Last Modified: 2010-04-17
I've got a series of Yes/No  fields and I want to allow the user to see which ones are checked. I've tried a couple things and I've decided to ask the experts. Here's what I've got:

set RSList = conn.execute("select * from inv order by make")

When I get to my checkboxes how do I reflect the "True" value?

<input type="checkbox" name="Powersteering" value="<% response.write RSList("PowerSteering") %>">

There's no error on the page, but no check mark either.

What do you think?
Question by:brucegust
    LVL 1

    Expert Comment

    I think this is what you need:

    Author Comment


    I'm not looking for the user to manually check the box. I need VBScript to look at the database and insert a checkmark into the checkbox where the status is "True".
    LVL 24

    Expert Comment

    Use checked=True not value=

    <input type="checkbox" name="Powersteering" checked="<% response.write RSList("PowerSteering") %>">

    Author Comment


    We're on the threshold of greatness, my friend, but I'm still missing something.

    When I introduced your code:

    <input type="checkbox" name="Powersteering" checked="<% response.write RSList("PowerSteering") %>">

    Every auto was displayed as having power steering which isn't the case. In other words, not every car has Power Steering, yet every Power Steering box is checked.


    Expert Comment

    I don't know if this is the most efficient way of doing it, but what I will typically do is write out one of two lines of HTML for the corresponding Checkbox element like this:

    <input type="checkbox" name="Powersteering" <%If RSList("PowerSteering") = True Then Response.Write "CHECKED">

    Doing it this way should at least display the checkboxes on the screen poperly. Saving the data back to the database would have to be handled separately.

    Hope this helps.


    Accepted Solution

    Syntax correction:

    <input type="checkbox" name="Powersteering" <%If RSList("PowerSteering") = True Then Response.Write "CHECKED"%>>

    Author Comment

    That got it!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Learn The Basics of Ethical Hacking & Pen Testing

    Computer and network security is one of the fastest growing and most essential industries in technology, meaning companies will pay big bucks for ethical hackers. This is the perfect course to leap into this lucrative career, learning how to use ethical hacking to reveal ...

    Suggested Solutions

    This article will show, step by step, how to integrate R code into a R Sweave document
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now