How to Check a Checkbox with a database results

  • I need help I am trying to use a database results to fill a form, but I dont

    know how to make a checkbox checked

    Thanks Dave

  • That depends on your development environment, but 0 (zero) usually represents an unchecked state, while 1, -1, or sometimes any non-zero value represents a checked state. Some dev environments even have built-in literals for "true" and "false" that work as well, and some have checkbox properties with values of "checked" and "unchecked". You can even fake it in environments without checkboxs by printing þ (Alt-0254) and ¨ (Alt-0168). When you change the font on those to "Wingdings", you get þ and ¨, respectively. You can even use that in Reporting Services, with an iif() function based on a field, for instance.

    If you tell us what you're using to build the form, someone could probably tell you what value is needed to represent a checked state.

  • I am using Front Page to create the form

    the checkbox states

    <input type="checkbox" name="C1" value="ON">

    initial state is not checked but value still = on when I submit the form I check where c1="on" to see if it is checked. so do I say that c1="on"  or c1=1  to get it checked?

    Thanks for help

    Dave

  • Best way to answer that one is for you to make an html page with 2 checkbox with the 2 different values and see what works.

     

    From what I remember of Javascript, the values true/false seemed to do the trick.  I'll let you whip up the tests and report back to us once you have the results.

  • It's been a while, but I do think that the back end needs a 0 or 1 in FrontPage.

  • just to clarify, an option or checkbox must have the CHECKED in it's definition:it's a keyword, and not the "value"

    <FORM METHOD=POST ACTION="">

    <INPUT TYPE="checkbox" NAME="firstcheck" value="Value to send Via GET or POST">

    <INPUT TYPE="checkbox" NAME="secondcheck" value="Value to send Via GET or POST" CHECKED>

    </FORM>

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply