By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

Checkbox Set To OFF Not In Request.Form

P: n/a
Dan
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?
Jul 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a

"Dan" <tr*****@gte.net> wrote in message
news:Os**************@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
Jul 19 '05 #2

P: n/a
> 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

Jul 19 '05 #3

P: n/a
> 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).


Jul 19 '05 #4

P: n/a
Dan
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:eJ*************@TK2MSFTNGP11.phx.gbl...

"Dan" <tr*****@gte.net> wrote in message
news:Os**************@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

Jul 19 '05 #5

P: n/a
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" <tr*****@gte.net> wrote in message
news:Ou**************@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:eJ*************@TK2MSFTNGP11.phx.gbl...

"Dan" <tr*****@gte.net> wrote in message
news:Os**************@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


Jul 19 '05 #6

P: n/a
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]
pw******@wandtv.com
WAND-TV (ABC Affiliate)
www.wandtv.com

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in
message news:OH**************@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" <tr*****@gte.net> wrote in message
news:Ou**************@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:eJ*************@TK2MSFTNGP11.phx.gbl...

"Dan" <tr*****@gte.net> wrote in message
news:Os**************@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



Jul 19 '05 #7

P: n/a
Dan
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" <aa***@TRASHaspfaq.com> wrote in message
news:ec**************@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

Jul 19 '05 #8

P: n/a
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:OA**************@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]
pw******@wandtv.com
WAND-TV (ABC Affiliate)
www.wandtv.com

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in
message news:OH**************@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" <tr*****@gte.net> wrote in message
news:Ou**************@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:eJ*************@TK2MSFTNGP11.phx.gbl...
>
> "Dan" <tr*****@gte.net> wrote in message
> news:Os**************@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
>
>



Jul 19 '05 #9

P: n/a
(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:OH****************@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" <tr*****@gte.net> wrote in message
news:Ou**************@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:eJ*************@TK2MSFTNGP11.phx.gbl...

"Dan" <tr*****@gte.net> wrote in message
news:Os**************@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



Jul 19 '05 #10

P: n/a
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]
pw******@wandtv.com
WAND-TV (ABC Affiliate)
www.wandtv.com

"Dan Sikorsky" <ds****@gte.net> wrote in message
news:e0**************@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

Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.