473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Checkbox Set To OFF Not In Request.Form

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
10 15617

"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
> 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
> 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
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
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
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
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
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
(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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mamun | last post by:
Hi All, I have the following case. I am trying to update a table based on the value of dropdown box and checkbox. Here is what I have in page1.asp <table>
2
by: RH | last post by:
I have a form with home address & business address fields. When a user goes to this form, the fields pull the information that is stored in the database, then they can update their information. ...
4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
3
by: Jack | last post by:
<i><input type="checkbox" name="chk_Complete" value="TRUE" <%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked" Else Response.Write " unchecked"%>> The above...
6
by: Dennis Allen | last post by:
Hi. I got a checkbox in a form. When the form is submitted, an email is generated. In the email text is the field name: on or off. The client doesn't want to see on or off, but yes or no. ...
7
by: Ron | last post by:
I have an HTML page, that calls an ASP javascript page on "Submit". Everything works correctly except that I can't get the value of the checkboxes. I've been trying code like this: var s = "Off"...
1
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
11
by: =?Utf-8?B?UGFyYWcgR2Fpa3dhZA==?= | last post by:
Hi All, I have a large recordset to be displayed on a ASP 3.0 page. I am using recordset paging for this. For the next and previous link i am passing href as <a href=<Page URl>?page=<%=...
4
by: Charlotte | last post by:
Hi, I have a problem with a ASP-script, can somewone help me ? here is what I've got: mypage.asp : .... code ... <%
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.