473,503 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capturing "checkbox" value

Don
Via JavaScript within the client page containing the checkbox, I'm trying to capture the value of a
checkbox to make a cookie out of it. But, all I get is the defined "ON" value, even when it is
unchecked. I'm using the following construct:

document.cookie = "cpceRememberLoginCookie="+document.getPage1.remem berLogin.value+"; expires=Thr,
01-Jan-2015 00:00:00 GMT";

The actual checkbox value passed in the <form> POST reflects the actual state of the checkbox.

Thanks for your help.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #1
7 2929

Don wrote:
Via JavaScript within the client page containing the checkbox, I'm trying to capture the value of a checkbox to make a cookie out of it. But, all I get is the defined "ON" value, even when it is unchecked. I'm using the following construct:

document.cookie = "cpceRememberLoginCookie="+document.getPage1.remem berLogin.value+";
expires=Thr, 01-Jan-2015 00:00:00 GMT";

The actual checkbox value passed in the <form> POST reflects the actual state of the checkbox.
Thanks for your help.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==---------- http://www.newsfeed.com The #1 Newsgroup Service in the World! -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19

Servers =-----

A checkbox functions within an HTML form by submitting the usual
*name=value* pair when checked, and *nothing* when not. All reading the
Checkbox.value property programmatically will get you is - the checkbox
value. ;) The default is "on" btw. You want the .checked property, a
Boolean. The concatenation will type-convert it to 'true' / 'false'.
Hope I understood your Q.

Jul 23 '05 #2
Don
On 20 Dec 2004 09:06:14 -0800, "RobB" <fe******@hotmail.com> wrote:

Don wrote:
Via JavaScript within the client page containing the checkbox, I'm

trying to capture the value of a
checkbox to make a cookie out of it. But, all I get is the defined

"ON" value, even when it is
unchecked. I'm using the following construct:

document.cookie =

"cpceRememberLoginCookie="+document.getPage1.reme mberLogin.value+";
expires=Thr,
01-Jan-2015 00:00:00 GMT";

The actual checkbox value passed in the <form> POST reflects the

actual state of the checkbox.

Thanks for your help.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News

==----------
http://www.newsfeed.com The #1 Newsgroup Service in the

World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19

Servers =-----

A checkbox functions within an HTML form by submitting the usual
*name=value* pair when checked, and *nothing* when not. All reading the
Checkbox.value property programmatically will get you is - the checkbox
value. ;) The default is "on" btw. You want the .checked property, a
Boolean. The concatenation will type-convert it to 'true' / 'false'.
Hope I understood your Q.

Thanks for your reply Rob. I think I understand what you're saying. What is the JS code to
reference the checked property (boolean)?

Thanks,
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #3

Don wrote:
On 20 Dec 2004 09:06:14 -0800, "RobB" <fe******@hotmail.com> wrote:

Don wrote:
Via JavaScript within the client page containing the checkbox, I'mtrying to capture the value of a
checkbox to make a cookie out of it. But, all I get is the
defined"ON" value, even when it is
unchecked. I'm using the following construct:

document.cookie =

"cpceRememberLoginCookie="+document.getPage1.reme mberLogin.value+";
expires=Thr,
01-Jan-2015 00:00:00 GMT";

The actual checkbox value passed in the <form> POST reflects the

actual state of the checkbox.

Thanks for your help.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News

==----------
http://www.newsfeed.com The #1 Newsgroup Service in the

World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19

Servers =-----

A checkbox functions within an HTML form by submitting the usual
*name=value* pair when checked, and *nothing* when not. All reading theCheckbox.value property programmatically will get you is - the checkboxvalue. ;) The default is "on" btw. You want the .checked property, a
Boolean. The concatenation will type-convert it to 'true' / 'false'.
Hope I understood your Q.

Thanks for your reply Rob. I think I understand what you're saying.

What is the JS code to reference the checked property (boolean)?

Thanks,
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==---------- http://www.newsfeed.com The #1 Newsgroup Service in the World! -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19

Servers =-----

Assuming there's only one element of that name, same as you're using -
with the substitution of 'checked' for 'value'. Or: give the cb an
id="foo" (or whatever) and use document.getElementById("foo").

If you want the actual value if checked, and nothing (empty string) if
unchecked, use:

document.cookie =
"cpceRememberLoginCookie=" +
((document.getPage1.rememberLogin.checked) ?
document.getPage1.rememberLogin.value : "") +
"; expires=Thr,01-Jan-2015 00:00:00 GMT" +
"; path=/";

http://www.quirksmode.org/js/cookies.html

Jul 23 '05 #4
Don
On 20 Dec 2004 11:13:08 -0800, "RobB" <fe******@hotmail.com> wrote:

Don wrote:
On 20 Dec 2004 09:06:14 -0800, "RobB" <fe******@hotmail.com> wrote:
>
>Don wrote:
>> Via JavaScript within the client page containing the checkbox, I'm
>trying to capture the value of a
>> checkbox to make a cookie out of it. But, all I get is thedefined >"ON" value, even when it is
>> unchecked. I'm using the following construct:
>>
>> document.cookie =
>"cpceRememberLoginCookie="+document.getPage1.reme mberLogin.value+";
>expires=Thr,
>> 01-Jan-2015 00:00:00 GMT";
>>
>> The actual checkbox value passed in the <form> POST reflects the
>actual state of the checkbox.
>>
>> Thanks for your help.
>> Don
>>
>>
>> -----------== Posted via Newsfeed.Com - Uncensored Usenet News
>==----------
>> http://www.newsfeed.com The #1 Newsgroup Service in the
>World!
>> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19
>Servers =-----
>
>A checkbox functions within an HTML form by submitting the usual
>*name=value* pair when checked, and *nothing* when not. All readingthe >Checkbox.value property programmatically will get you is - thecheckbox >value. ;) The default is "on" btw. You want the .checked property, a
>Boolean. The concatenation will type-convert it to 'true' / 'false'.
>Hope I understood your Q.

Thanks for your reply Rob. I think I understand what you're saying.

What is the JS code to
reference the checked property (boolean)?

Thanks,
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News

==----------
http://www.newsfeed.com The #1 Newsgroup Service in the

World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19

Servers =-----

Assuming there's only one element of that name, same as you're using -
with the substitution of 'checked' for 'value'. Or: give the cb an
id="foo" (or whatever) and use document.getElementById("foo").

If you want the actual value if checked, and nothing (empty string) if
unchecked, use:

document.cookie =
"cpceRememberLoginCookie=" +
((document.getPage1.rememberLogin.checked) ?
document.getPage1.rememberLogin.value : "") +
"; expires=Thr,01-Jan-2015 00:00:00 GMT" +
"; path=/";

http://www.quirksmode.org/js/cookies.html

Thanks Rob. However, I'm not sure I understand the use of "?" and ":" in the following:
((document.getPage1.rememberLogin.checked) ? document.getPage1.rememberLogin.value : "").
Could you explain that please.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #5

Don wrote:
On 20 Dec 2004 11:13:08 -0800, "RobB" <fe******@hotmail.com> wrote:

Don wrote:
On 20 Dec 2004 09:06:14 -0800, "RobB" <fe******@hotmail.com> wrote:
>
>Don wrote:
>> Via JavaScript within the client page containing the checkbox, I'm >trying to capture the value of a
>> checkbox to make a cookie out of it. But, all I get is thedefined
>"ON" value, even when it is
>> unchecked. I'm using the following construct:
>>
>> document.cookie =
"cpceRememberLoginCookie="+document.getPage1.reme mberLogin.value+"; >expires=Thr,
>> 01-Jan-2015 00:00:00 GMT";
>>
>> The actual checkbox value passed in the <form> POST reflects the >actual state of the checkbox.
>>
>> Thanks for your help.
>> Don
>>
>>
>> -----------== Posted via Newsfeed.Com - Uncensored Usenet News
>==----------
>> http://www.newsfeed.com The #1 Newsgroup Service in the >World!
>> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19
>Servers =-----
>
>A checkbox functions within an HTML form by submitting the usual
>*name=value* pair when checked, and *nothing* when not. All reading
the
>Checkbox.value property programmatically will get you is - the

checkbox
>value. ;) The default is "on" btw. You want the .checked
property, a >Boolean. The concatenation will type-convert it to 'true' / 'false'. >Hope I understood your Q.
Thanks for your reply Rob. I think I understand what you're

saying.What is the JS code to
reference the checked property (boolean)?

Thanks,
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News

==----------
http://www.newsfeed.com The #1 Newsgroup Service in the

World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19

Servers =-----

Assuming there's only one element of that name, same as you're using -with the substitution of 'checked' for 'value'. Or: give the cb an
id="foo" (or whatever) and use document.getElementById("foo").

If you want the actual value if checked, and nothing (empty string) ifunchecked, use:

document.cookie =
"cpceRememberLoginCookie=" +
((document.getPage1.rememberLogin.checked) ?
document.getPage1.rememberLogin.value : "") +
"; expires=Thr,01-Jan-2015 00:00:00 GMT" +
"; path=/";

http://www.quirksmode.org/js/cookies.html

Thanks Rob. However, I'm not sure I understand the use of "?" and

":" in the following: ((document.getPage1.rememberLogin.checked) ? document.getPage1.rememberLogin.value : ""). Could you explain that please.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==---------- http://www.newsfeed.com The #1 Newsgroup Service in the World! -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19

Servers =-----

Conditional operator [ (condition) ? if-true : if-false ]

((document.getPage1.rememberLogin.checked) ? ---> box checked?
document.getPage1.rememberLogin.value ---> yes, get value
: ---> else
"") ---> no, use empty string

Just a more compact form of if-else. Can be cascaded:

(condition) ? if-true : (2nd condition) ? if-true : (3rd condition) ?
if-true : if-false
....something like switch/case. The latter is faster, however.

Jul 23 '05 #6
Don
On 20 Dec 2004 12:23:01 -0800, "RobB" <fe******@hotmail.com> wrote:

Don wrote:
On 20 Dec 2004 11:13:08 -0800, "RobB" <fe******@hotmail.com> wrote:
>
>Don wrote:
>> On 20 Dec 2004 09:06:14 -0800, "RobB" <fe******@hotmail.com>wrote: >>
>> >
>> >Don wrote:
>> >> Via JavaScript within the client page containing the checkbox,I'm >> >trying to capture the value of a
>> >> checkbox to make a cookie out of it. But, all I get is the
>defined
>> >"ON" value, even when it is
>> >> unchecked. I'm using the following construct:
>> >>
>> >> document.cookie =
>>

"cpceRememberLoginCookie="+document.getPage1.rem emberLogin.value+";
>> >expires=Thr,
>> >> 01-Jan-2015 00:00:00 GMT";
>> >>
>> >> The actual checkbox value passed in the <form> POST reflectsthe >> >actual state of the checkbox.
>> >>
>> >> Thanks for your help.
>> >> Don
>> >>
>> >>
>> >> -----------== Posted via Newsfeed.Com - Uncensored Usenet News
>> >==----------
>> >> http://www.newsfeed.com The #1 Newsgroup Service inthe >> >World!
>> >> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19
>> >Servers =-----
>> >
>> >A checkbox functions within an HTML form by submitting the usual
>> >*name=value* pair when checked, and *nothing* when not. Allreading >the
>> >Checkbox.value property programmatically will get you is - the
>checkbox
>> >value. ;) The default is "on" btw. You want the .checkedproperty, a >> >Boolean. The concatenation will type-convert it to 'true' /'false'. >> >Hope I understood your Q.
>> Thanks for your reply Rob. I think I understand what you'resaying. >What is the JS code to
>> reference the checked property (boolean)?
>>
>> Thanks,
>> Don
>>
>>
>> -----------== Posted via Newsfeed.Com - Uncensored Usenet News
>==----------
>> http://www.newsfeed.com The #1 Newsgroup Service in the
>World!
>> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19
>Servers =-----
>
>Assuming there's only one element of that name, same as you're using- >with the substitution of 'checked' for 'value'. Or: give the cb an
>id="foo" (or whatever) and use document.getElementById("foo").
>
>If you want the actual value if checked, and nothing (empty string)if >unchecked, use:
>
>document.cookie =
>"cpceRememberLoginCookie=" +
>((document.getPage1.rememberLogin.checked) ?
>document.getPage1.rememberLogin.value : "") +
>"; expires=Thr,01-Jan-2015 00:00:00 GMT" +
>"; path=/";
>
>http://www.quirksmode.org/js/cookies.html

Thanks Rob. However, I'm not sure I understand the use of "?" and

":" in the following:
((document.getPage1.rememberLogin.checked) ?

document.getPage1.rememberLogin.value : "").
Could you explain that please.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News

==----------
http://www.newsfeed.com The #1 Newsgroup Service in the

World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19

Servers =-----

Conditional operator [ (condition) ? if-true : if-false ]

((document.getPage1.rememberLogin.checked) ? ---> box checked?
document.getPage1.rememberLogin.value ---> yes, get value
: ---> else
"") ---> no, use empty string

Just a more compact form of if-else. Can be cascaded:

(condition) ? if-true : (2nd condition) ? if-true : (3rd condition) ?
if-true : if-false
...something like switch/case. The latter is faster, however.

I see. That makes sense now. I'm anxious to give it a try. Gotta go do some Christmas shopping
right now. Thanks again, and have a very Happy Holiday Season.
Don
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
Jul 23 '05 #7
Same to you Don ! :>)

Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
29327
by: John E | last post by:
How do I get whether a checkbox is ticked in a form on a form's submission (true or false)? How do I use the Request object in ASP?
5
21178
by: PhiSYS | last post by:
I want to know what's wrong with this code (I'm an amateur programmer). I'm trying to check if every field has a value or if checkboxes/radios have at least one item checked on each group (yes, you...
3
37828
by: F. Da Costa | last post by:
Hi, Does the following indeed imply that this event is NOT called when an <input type="checkbox" is toggled? This would thus imply the usage of the onClick handler instead (assuming an action...
2
5297
by: soundar rajan | last post by:
Hi, I wanna display messagebox, and also at the bottom i wanna display "Dont show again" with checkbox using VB.NET. Immediate help needed!!!!
2
6391
by: Andrew | last post by:
Hi, I have a problem capturing the checkboxes that are checked, I get false irrespective of wether they are checked or not. I have gone thru the sample code on this forum, but they dun seem to...
7
2888
by: Jaime Stuardo | last post by:
Hi all.. I have a DataGrid with checkboxes. In the header I have a "check all" checkbox. I'm wondering if there is an easy way to check all checkboxes using that checkbox. I could do it using...
1
4011
by: spolsky | last post by:
try the the following code with Opera 9.01 (Windows). when clicked slightly faster than normal clicking, the toggler checkbox and other checkboxes displays differently although event method works...
1
5287
by: ascll | last post by:
Hi, Do you guy know how to make a ASP.net 2.0 checkbox "read-only"? Thanks.
1
12540
by: rando1000 | last post by:
So I have this form that captures Me.CheckboxName.Value as part of an SQL statement. For one checkbox, it evaluates as 0, which is great, because I'm filling a Yes/No field with it. But for another...
0
7086
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
7330
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...
1
6991
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
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
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,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.