471,066 Members | 1,186 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 2774

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by F. Da Costa | last post: by
2 posts views Thread by soundar rajan | last post: by
7 posts views Thread by Jaime Stuardo | last post: by
1 post views Thread by spolsky | last post: by
1 post views Thread by ascll | last post: by

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.