Checkbox Set To OFF Not In Request.Form

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Checkbox Set To OFF Not In Request.Form

    When using checkboxes on a form, if you uncheck them, the unchecked
    name/value pair in the Request.Form collection doesn't show up. It only
    shows when the checkbox is set to ON.

    Is this correct? What's the workaround if it is?


    Dan Guest

  2. Similar Questions and Discussions

    1. How do I use the form checkbox value?
      I'm creating a form that has multiple checkboxes. I want to use ActionScript to update a text box/area with the values each checkbox as the checkbox...
    2. Flash Form & Checkbox
      I'm having trouble changing this listbox code to checkboxes instead. Can you help? <cfselect name="binderyID" label = "Bindery Type"...
    3. Confused about a REQUEST.FORM and a REQUEST.QUERYSTRING
      This is snipit of code, supplied by PayPal with explanation about what has to be done to access their back end. I am confused because they first...
    4. Yes/No checkbox in the form
      I have a field called action in a table, to check if something requires action the user must check the box. The field in the table is defined as a...
    5. best way to get data: request.form, request.params, controlname.value
      Hi! I think I remember somewhere that using request.form was a bad idea (I can't say I remember why). So I'm wondering: What is the best way to...
  3. #2

    Default Re: Checkbox Set To OFF Not In Request.Form


    "Dan" <trdwnds@gte.net> wrote in message
    news:OsZHynokDHA.3256@tk2msftngp13.phx.gbl...
    > When using checkboxes on a form, if you uncheck them, the unchecked
    > name/value pair in the Request.Form collection doesn't show up. It only
    > shows when the checkbox is set to ON.
    >
    > Is this correct?
    Yes it is.
    > What's the workaround if it is?
    That depends on what you're trying to do. What are you trying to do?

    Ray at work


    Ray at Guest

  4. #3

    Default Re: Checkbox Set To OFF Not In Request.Form

    > Is this correct?

    Yep.
    > What's the workaround if it is?
    Well, that depends. If you are trying to store state in a database, rather
    than trying to figure out what checkboxes WEREN'T checked, is I clear the
    data and then start fresh with only the options that were checked. This
    logic is much easier, and works well with checkboxes that are generated
    dynamically...

    Other things you can do:

    <input type=hidden name=possible value='a, b, c'>
    <input type=checkbox name=actual value='a'> A
    <input type=checkbox name=actual value='b'> B
    <input type=checkbox name=actual value='c'> C

    Then on the receiving page, you can compare the strings. If they differ,
    you can use split to determine which elements are still in possible that
    aren't in actual (previously checked but no longer checked).

    A



    Aaron Bertrand - MVP Guest

  5. #4

    Default Re: Checkbox Set To OFF Not In Request.Form

    > Then on the receiving page, you can compare the strings. If they differ,
    > you can use split to determine which elements are still in possible that
    > aren't in actual (previously checked but no longer checked).
    Oh and you can also determine which ones were previously unchecked and now
    are checked, e.g.

    <input type=hidden name=possible value='a, b, c'>
    <input type=hidden name=previous value='a, b'>
    <input type=checkbox name=actual value='a' CHECKED> A
    <input type=checkbox name=actual value='b' CHECKED> B
    <input type=checkbox name=actual value='c'> C

    Now, you can compare actual to possible (to determine those that are
    unchecked) and you can also compare actual to previous (to determine both
    those that were previously checked and have been turned off, and those that
    were previously unchecked and have been turned on).




    Aaron Bertrand - MVP Guest

  6. #5

    Default Re: Checkbox Set To OFF Not In Request.Form

    I'm trying to implement a SQL Server 2000 'edit record' page that has BIT
    fields (boolean value).


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:eJMSBqokDHA.644@TK2MSFTNGP11.phx.gbl...
    >
    > "Dan" <trdwnds@gte.net> wrote in message
    > news:OsZHynokDHA.3256@tk2msftngp13.phx.gbl...
    > > When using checkboxes on a form, if you uncheck them, the unchecked
    > > name/value pair in the Request.Form collection doesn't show up. It only
    > > shows when the checkbox is set to ON.
    > >
    > > Is this correct?
    >
    > Yes it is.
    >
    > > What's the workaround if it is?
    > That depends on what you're trying to do. What are you trying to do?
    >
    > Ray at work
    >
    >

    Dan Guest

  7. #6

    Default Re: Checkbox Set To OFF Not In Request.Form

    Uh, fine. :] But, what are you trying to do that requires that you know if
    a checkbox has been unchecked? What Aaron suggested will typically work for
    most things. The synapse between your explanation below and the checkbox
    query is a bit too large.

    Ray at work

    "Dan" <trdwnds@gte.net> wrote in message
    news:OuXiR8okDHA.1096@TK2MSFTNGP11.phx.gbl...
    > I'm trying to implement a SQL Server 2000 'edit record' page that has BIT
    > fields (boolean value).
    >
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:eJMSBqokDHA.644@TK2MSFTNGP11.phx.gbl...
    > >
    > > "Dan" <trdwnds@gte.net> wrote in message
    > > news:OsZHynokDHA.3256@tk2msftngp13.phx.gbl...
    > > > When using checkboxes on a form, if you uncheck them, the unchecked
    > > > name/value pair in the Request.Form collection doesn't show up. It
    only
    > > > shows when the checkbox is set to ON.
    > > >
    > > > Is this correct?
    > >
    > > Yes it is.
    > >
    > > > What's the workaround if it is?
    > > That depends on what you're trying to do. What are you trying to do?
    > >
    > > Ray at work
    > >
    > >
    >
    >

    Ray at Guest

  8. #7

    Default Re: Checkbox Set To OFF Not In Request.Form

    Why not just this:

    MyVar = Request.Form("MyCheckBox")
    If MyVar <> "ON" Then MyVar = "OFF"

    'Now the MyVar will either be "ON" or it will be "OFF"


    --

    Phillip Windell [CCNA, MVP, MCP]
    [email]pwindell@wandtv.com[/email]
    WAND-TV (ABC Affiliate)
    [url]www.wandtv.com[/url]

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in
    message news:OHIAp#okDHA.1096@TK2MSFTNGP11.phx.gbl...
    > Uh, fine. :] But, what are you trying to do that requires that you
    know if
    > a checkbox has been unchecked? What Aaron suggested will typically
    work for
    > most things. The synapse between your explanation below and the
    checkbox
    > query is a bit too large.
    >
    > Ray at work
    >
    > "Dan" <trdwnds@gte.net> wrote in message
    > news:OuXiR8okDHA.1096@TK2MSFTNGP11.phx.gbl...
    > > I'm trying to implement a SQL Server 2000 'edit record' page that
    has BIT
    > > fields (boolean value).
    > >
    > >
    > > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in
    message
    > > news:eJMSBqokDHA.644@TK2MSFTNGP11.phx.gbl...
    > > >
    > > > "Dan" <trdwnds@gte.net> wrote in message
    > > > news:OsZHynokDHA.3256@tk2msftngp13.phx.gbl...
    > > > > When using checkboxes on a form, if you uncheck them, the
    unchecked
    > > > > name/value pair in the Request.Form collection doesn't show
    up. It
    > only
    > > > > shows when the checkbox is set to ON.
    > > > >
    > > > > Is this correct?
    > > >
    > > > Yes it is.
    > > >
    > > > > What's the workaround if it is?
    > > > That depends on what you're trying to do. What are you trying
    to do?
    > > >
    > > > Ray at work
    > > >
    > > >
    > >
    > >
    >
    >

    Phillip Windell Guest

  9. #8

    Default Re: Checkbox Set To OFF Not In Request.Form

    I have a canned routine that reads the Request.Form collection and prepares
    the INSERT or UPDATE statement. If a checkbox is initially checked, and is
    then unchecked, that field name won't make it into the Request.Form
    collection for the auto-generation of the SQL UPDATE statement without a
    changing my canned routine that's heretofore been working fine (without the
    use of checkboxes on the form). So, I'll modify my routine to detect this
    special handling.


    "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    news:ecHyWvokDHA.2200@TK2MSFTNGP12.phx.gbl...
    > > Is this correct?
    >
    > Yep.
    >
    > > What's the workaround if it is?
    >
    > Well, that depends. If you are trying to store state in a database,
    rather
    > than trying to figure out what checkboxes WEREN'T checked, is I clear the
    > data and then start fresh with only the options that were checked. This
    > logic is much easier, and works well with checkboxes that are generated
    > dynamically...
    >
    > Other things you can do:
    >
    > <input type=hidden name=possible value='a, b, c'>
    > <input type=checkbox name=actual value='a'> A
    > <input type=checkbox name=actual value='b'> B
    > <input type=checkbox name=actual value='c'> C
    >
    > Then on the receiving page, you can compare the strings. If they differ,
    > you can use split to determine which elements are still in possible that
    > aren't in actual (previously checked but no longer checked).
    >
    > A
    >
    >
    >

    Dan Guest

  10. #9

    Default Re: Checkbox Set To OFF Not In Request.Form

    Your solution will handle a particular case, but I need to detect state info
    (see my response to Aaron Bertrand).

    --
    Thank you,

    Dan Sikorsky MSCS, BSCE, BAB


    "Phillip Windell" <pwindell{at}wandtv*d0t*com> wrote in message
    news:OA7tBLpkDHA.3700@TK2MSFTNGP11.phx.gbl...
    > Why not just this:
    >
    > MyVar = Request.Form("MyCheckBox")
    > If MyVar <> "ON" Then MyVar = "OFF"
    >
    > 'Now the MyVar will either be "ON" or it will be "OFF"
    >
    >
    > --
    >
    > Phillip Windell [CCNA, MVP, MCP]
    > [email]pwindell@wandtv.com[/email]
    > WAND-TV (ABC Affiliate)
    > [url]www.wandtv.com[/url]
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in
    > message news:OHIAp#okDHA.1096@TK2MSFTNGP11.phx.gbl...
    > > Uh, fine. :] But, what are you trying to do that requires that you
    > know if
    > > a checkbox has been unchecked? What Aaron suggested will typically
    > work for
    > > most things. The synapse between your explanation below and the
    > checkbox
    > > query is a bit too large.
    > >
    > > Ray at work
    > >
    > > "Dan" <trdwnds@gte.net> wrote in message
    > > news:OuXiR8okDHA.1096@TK2MSFTNGP11.phx.gbl...
    > > > I'm trying to implement a SQL Server 2000 'edit record' page that
    > has BIT
    > > > fields (boolean value).
    > > >
    > > >
    > > > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in
    > message
    > > > news:eJMSBqokDHA.644@TK2MSFTNGP11.phx.gbl...
    > > > >
    > > > > "Dan" <trdwnds@gte.net> wrote in message
    > > > > news:OsZHynokDHA.3256@tk2msftngp13.phx.gbl...
    > > > > > When using checkboxes on a form, if you uncheck them, the
    > unchecked
    > > > > > name/value pair in the Request.Form collection doesn't show
    > up. It
    > > only
    > > > > > shows when the checkbox is set to ON.
    > > > > >
    > > > > > Is this correct?
    > > > >
    > > > > Yes it is.
    > > > >
    > > > > > What's the workaround if it is?
    > > > > That depends on what you're trying to do. What are you trying
    > to do?
    > > > >
    > > > > Ray at work
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Dan Sikorsky Guest

  11. #10

    Default Re: Checkbox Set To OFF Not In Request.Form

    (see my response to Aaron Bertrand)

    --
    Thank you,

    Dan Sikorsky MSCS, BSCE, BAB


    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:OHIAp%23okDHA.1096@TK2MSFTNGP11.phx.gbl...
    > Uh, fine. :] But, what are you trying to do that requires that you know
    if
    > a checkbox has been unchecked? What Aaron suggested will typically work
    for
    > most things. The synapse between your explanation below and the checkbox
    > query is a bit too large.
    >
    > Ray at work
    >
    > "Dan" <trdwnds@gte.net> wrote in message
    > news:OuXiR8okDHA.1096@TK2MSFTNGP11.phx.gbl...
    > > I'm trying to implement a SQL Server 2000 'edit record' page that has
    BIT
    > > fields (boolean value).
    > >
    > >
    > > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > > news:eJMSBqokDHA.644@TK2MSFTNGP11.phx.gbl...
    > > >
    > > > "Dan" <trdwnds@gte.net> wrote in message
    > > > news:OsZHynokDHA.3256@tk2msftngp13.phx.gbl...
    > > > > When using checkboxes on a form, if you uncheck them, the unchecked
    > > > > name/value pair in the Request.Form collection doesn't show up. It
    > only
    > > > > shows when the checkbox is set to ON.
    > > > >
    > > > > Is this correct?
    > > >
    > > > Yes it is.
    > > >
    > > > > What's the workaround if it is?
    > > > That depends on what you're trying to do. What are you trying to do?
    > > >
    > > > Ray at work
    > > >
    > > >
    > >
    > >
    >
    >

    Dan Sikorsky Guest

  12. #11

    Default Re: Checkbox Set To OFF Not In Request.Form

    I looked and I don't see the problem. I don't see "detecting state"
    having any bearing on it. Yes you routine that gathers the values
    would have to change, but that is kinda a "given".

    --

    Phillip Windell [CCNA, MVP, MCP]
    [email]pwindell@wandtv.com[/email]
    WAND-TV (ABC Affiliate)
    [url]www.wandtv.com[/url]

    "Dan Sikorsky" <dsikor@gte.net> wrote in message
    news:e0odVuykDHA.3732@tk2msftngp13.phx.gbl...
    > Your solution will handle a particular case, but I need to detect
    state info
    > (see my response to Aaron Bertrand).
    >
    > --
    > Thank you,
    >
    > Dan Sikorsky MSCS, BSCE, BAB

    Phillip Windell Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139