Capturing "checkbox" value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don

    Capturing "checkbox" value

    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 = "cpceRememberLo ginCookie="+doc ument.getPage1. rememberLogin.v alue+"; 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 =-----
  • RobB

    #2
    Re: Capturing &quot;checkbox& quot; value


    Don wrote:[color=blue]
    > Via JavaScript within the client page containing the checkbox, I'm[/color]
    trying to capture the value of a[color=blue]
    > checkbox to make a cookie out of it. But, all I get is the defined[/color]
    "ON" value, even when it is[color=blue]
    > unchecked. I'm using the following construct:
    >
    > document.cookie =[/color]
    "cpceRememberLo ginCookie="+doc ument.getPage1. rememberLogin.v alue+";
    expires=Thr,[color=blue]
    > 01-Jan-2015 00:00:00 GMT";
    >
    > The actual checkbox value passed in the <form> POST reflects the[/color]
    actual state of the checkbox.[color=blue]
    >
    > Thanks for your help.
    > Don
    >
    >
    > -----------== Posted via Newsfeed.Com - Uncensored Usenet News[/color]
    ==----------[color=blue]
    > http://www.newsfeed.com The #1 Newsgroup Service in the[/color]
    World![color=blue]
    > -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19[/color]
    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 programmaticall y 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.

    Comment

    • Don

      #3
      Re: Capturing &quot;checkbox& quot; value

      On 20 Dec 2004 09:06:14 -0800, "RobB" <ferndoc9@hotma il.com> wrote:
      [color=blue]
      >
      >Don wrote:[color=green]
      >> Via JavaScript within the client page containing the checkbox, I'm[/color]
      >trying to capture the value of a[color=green]
      >> checkbox to make a cookie out of it. But, all I get is the defined[/color]
      >"ON" value, even when it is[color=green]
      >> unchecked. I'm using the following construct:
      >>
      >> document.cookie =[/color]
      >"cpceRememberL oginCookie="+do cument.getPage1 .rememberLogin. value+";
      >expires=Thr,[color=green]
      >> 01-Jan-2015 00:00:00 GMT";
      >>
      >> The actual checkbox value passed in the <form> POST reflects the[/color]
      >actual state of the checkbox.[color=green]
      >>
      >> Thanks for your help.
      >> Don
      >>
      >>
      >> -----------== Posted via Newsfeed.Com - Uncensored Usenet News[/color]
      >==----------[color=green]
      >> http://www.newsfeed.com The #1 Newsgroup Service in the[/color]
      >World![color=green]
      >> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19[/color]
      >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.val ue property programmaticall y 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.[/color]
      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 =-----

      Comment

      • RobB

        #4
        Re: Capturing &quot;checkbox& quot; value


        Don wrote:[color=blue]
        > On 20 Dec 2004 09:06:14 -0800, "RobB" <ferndoc9@hotma il.com> wrote:
        >[color=green]
        > >
        > >Don wrote:[color=darkred]
        > >> Via JavaScript within the client page containing the checkbox, I'm[/color]
        > >trying to capture the value of a[color=darkred]
        > >> checkbox to make a cookie out of it. But, all I get is the[/color][/color][/color]
        defined[color=blue][color=green]
        > >"ON" value, even when it is[color=darkred]
        > >> unchecked. I'm using the following construct:
        > >>
        > >> document.cookie =[/color]
        > >"cpceRememberL oginCookie="+do cument.getPage1 .rememberLogin. value+";
        > >expires=Thr,[color=darkred]
        > >> 01-Jan-2015 00:00:00 GMT";
        > >>
        > >> The actual checkbox value passed in the <form> POST reflects the[/color]
        > >actual state of the checkbox.[color=darkred]
        > >>
        > >> Thanks for your help.
        > >> Don
        > >>
        > >>
        > >> -----------== Posted via Newsfeed.Com - Uncensored Usenet News[/color]
        > >==----------[color=darkred]
        > >> http://www.newsfeed.com The #1 Newsgroup Service in the[/color]
        > >World![color=darkred]
        > >> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19[/color]
        > >Servers =-----
        > >
        > >A checkbox functions within an HTML form by submitting the usual
        > >*name=value* pair when checked, and *nothing* when not. All reading[/color][/color]
        the[color=blue][color=green]
        > >Checkbox.val ue property programmaticall y will get you is - the[/color][/color]
        checkbox[color=blue][color=green]
        > >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.[/color]
        > Thanks for your reply Rob. I think I understand what you're saying.[/color]
        What is the JS code to[color=blue]
        > reference the checked property (boolean)?
        >
        > Thanks,
        > Don
        >
        >
        > -----------== Posted via Newsfeed.Com - Uncensored Usenet News[/color]
        ==----------[color=blue]
        > http://www.newsfeed.com The #1 Newsgroup Service in the[/color]
        World![color=blue]
        > -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19[/color]
        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.getEle mentById("foo") .

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

        document.cookie =
        "cpceRememberLo ginCookie=" +
        ((document.getP age1.rememberLo gin.checked) ?
        document.getPag e1.rememberLogi n.value : "") +
        "; expires=Thr,01-Jan-2015 00:00:00 GMT" +
        "; path=/";



        Comment

        • Don

          #5
          Re: Capturing &quot;checkbox& quot; value

          On 20 Dec 2004 11:13:08 -0800, "RobB" <ferndoc9@hotma il.com> wrote:
          [color=blue]
          >
          >Don wrote:[color=green]
          >> On 20 Dec 2004 09:06:14 -0800, "RobB" <ferndoc9@hotma il.com> wrote:
          >>[color=darkred]
          >> >
          >> >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[/color][/color]
          >defined[color=green][color=darkred]
          >> >"ON" value, even when it is
          >> >> unchecked. I'm using the following construct:
          >> >>
          >> >> document.cookie =
          >> >"cpceRememberL oginCookie="+do cument.getPage1 .rememberLogin. 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[/color][/color]
          >the[color=green][color=darkred]
          >> >Checkbox.val ue property programmaticall y will get you is - the[/color][/color]
          >checkbox[color=green][color=darkred]
          >> >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.[/color]
          >> Thanks for your reply Rob. I think I understand what you're saying.[/color]
          >What is the JS code to[color=green]
          >> reference the checked property (boolean)?
          >>
          >> Thanks,
          >> Don
          >>
          >>
          >> -----------== Posted via Newsfeed.Com - Uncensored Usenet News[/color]
          >==----------[color=green]
          >> http://www.newsfeed.com The #1 Newsgroup Service in the[/color]
          >World![color=green]
          >> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19[/color]
          >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.getEle mentById("foo") .
          >
          >If you want the actual value if checked, and nothing (empty string) if
          >unchecked, use:
          >
          >document.cooki e =
          >"cpceRememberL oginCookie=" +
          >((document.get Page1.rememberL ogin.checked) ?
          >document.getPa ge1.rememberLog in.value : "") +
          >"; expires=Thr,01-Jan-2015 00:00:00 GMT" +
          >"; path=/";
          >
          >http://www.quirksmode.org/js/cookies.html[/color]
          Thanks Rob. However, I'm not sure I understand the use of "?" and ":" in the following:
          ((document.getP age1.rememberLo gin.checked) ? document.getPag e1.rememberLogi n.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 =-----

          Comment

          • RobB

            #6
            Re: Capturing &quot;checkbox& quot; value


            Don wrote:[color=blue]
            > On 20 Dec 2004 11:13:08 -0800, "RobB" <ferndoc9@hotma il.com> wrote:
            >[color=green]
            > >
            > >Don wrote:[color=darkred]
            > >> On 20 Dec 2004 09:06:14 -0800, "RobB" <ferndoc9@hotma il.com>[/color][/color][/color]
            wrote:[color=blue][color=green][color=darkred]
            > >>
            > >> >
            > >> >Don wrote:
            > >> >> Via JavaScript within the client page containing the checkbox,[/color][/color][/color]
            I'm[color=blue][color=green][color=darkred]
            > >> >trying to capture the value of a
            > >> >> checkbox to make a cookie out of it. But, all I get is the[/color]
            > >defined[color=darkred]
            > >> >"ON" value, even when it is
            > >> >> unchecked. I'm using the following construct:
            > >> >>
            > >> >> document.cookie =
            > >>[/color][/color]
            >"cpceRememberL oginCookie="+do cument.getPage1 .rememberLogin. value+";[color=green][color=darkred]
            > >> >expires=Thr,
            > >> >> 01-Jan-2015 00:00:00 GMT";
            > >> >>
            > >> >> The actual checkbox value passed in the <form> POST reflects[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > >> >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[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > >> >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[/color][/color][/color]
            reading[color=blue][color=green]
            > >the[color=darkred]
            > >> >Checkbox.val ue property programmaticall y will get you is - the[/color]
            > >checkbox[color=darkred]
            > >> >value. ;) The default is "on" btw. You want the .checked[/color][/color][/color]
            property, a[color=blue][color=green][color=darkred]
            > >> >Boolean. The concatenation will type-convert it to 'true' /[/color][/color][/color]
            'false'.[color=blue][color=green][color=darkred]
            > >> >Hope I understood your Q.
            > >> Thanks for your reply Rob. I think I understand what you're[/color][/color][/color]
            saying.[color=blue][color=green]
            > >What is the JS code to[color=darkred]
            > >> reference the checked property (boolean)?
            > >>
            > >> Thanks,
            > >> Don
            > >>
            > >>
            > >> -----------== Posted via Newsfeed.Com - Uncensored Usenet News[/color]
            > >==----------[color=darkred]
            > >> http://www.newsfeed.com The #1 Newsgroup Service in the[/color]
            > >World![color=darkred]
            > >> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19[/color]
            > >Servers =-----
            > >
            > >Assuming there's only one element of that name, same as you're using[/color][/color]
            -[color=blue][color=green]
            > >with the substitution of 'checked' for 'value'. Or: give the cb an
            > >id="foo" (or whatever) and use document.getEle mentById("foo") .
            > >
            > >If you want the actual value if checked, and nothing (empty string)[/color][/color]
            if[color=blue][color=green]
            > >unchecked, use:
            > >
            > >document.cooki e =
            > >"cpceRememberL oginCookie=" +
            > >((document.get Page1.rememberL ogin.checked) ?
            > >document.getPa ge1.rememberLog in.value : "") +
            > >"; expires=Thr,01-Jan-2015 00:00:00 GMT" +
            > >"; path=/";
            > >
            > >http://www.quirksmode.org/js/cookies.html[/color]
            > Thanks Rob. However, I'm not sure I understand the use of "?" and[/color]
            ":" in the following:[color=blue]
            > ((document.getP age1.rememberLo gin.checked) ?[/color]
            document.getPag e1.rememberLogi n.value : "").[color=blue]
            > Could you explain that please.
            > Don
            >
            >
            > -----------== Posted via Newsfeed.Com - Uncensored Usenet News[/color]
            ==----------[color=blue]
            > http://www.newsfeed.com The #1 Newsgroup Service in the[/color]
            World![color=blue]
            > -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19[/color]
            Servers =-----

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

            ((document.getP age1.rememberLo gin.checked) ? ---> box checked?
            document.getPag e1.rememberLogi n.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.

            Comment

            • Don

              #7
              Re: Capturing &quot;checkbox& quot; value

              On 20 Dec 2004 12:23:01 -0800, "RobB" <ferndoc9@hotma il.com> wrote:
              [color=blue]
              >
              >Don wrote:[color=green]
              >> On 20 Dec 2004 11:13:08 -0800, "RobB" <ferndoc9@hotma il.com> wrote:
              >>[color=darkred]
              >> >
              >> >Don wrote:
              >> >> On 20 Dec 2004 09:06:14 -0800, "RobB" <ferndoc9@hotma il.com>[/color][/color]
              >wrote:[color=green][color=darkred]
              >> >>
              >> >> >
              >> >> >Don wrote:
              >> >> >> Via JavaScript within the client page containing the checkbox,[/color][/color]
              >I'm[color=green][color=darkred]
              >> >> >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 =
              >> >>[/color]
              >>"cpceRemember LoginCookie="+d ocument.getPage 1.rememberLogin .value+";[color=darkred]
              >> >> >expires=Thr,
              >> >> >> 01-Jan-2015 00:00:00 GMT";
              >> >> >>
              >> >> >> The actual checkbox value passed in the <form> POST reflects[/color][/color]
              >the[color=green][color=darkred]
              >> >> >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[/color][/color]
              >the[color=green][color=darkred]
              >> >> >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[/color][/color]
              >reading[color=green][color=darkred]
              >> >the
              >> >> >Checkbox.val ue property programmaticall y will get you is - the
              >> >checkbox
              >> >> >value. ;) The default is "on" btw. You want the .checked[/color][/color]
              >property, a[color=green][color=darkred]
              >> >> >Boolean. The concatenation will type-convert it to 'true' /[/color][/color]
              >'false'.[color=green][color=darkred]
              >> >> >Hope I understood your Q.
              >> >> Thanks for your reply Rob. I think I understand what you're[/color][/color]
              >saying.[color=green][color=darkred]
              >> >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[/color][/color]
              >-[color=green][color=darkred]
              >> >with the substitution of 'checked' for 'value'. Or: give the cb an
              >> >id="foo" (or whatever) and use document.getEle mentById("foo") .
              >> >
              >> >If you want the actual value if checked, and nothing (empty string)[/color][/color]
              >if[color=green][color=darkred]
              >> >unchecked, use:
              >> >
              >> >document.cooki e =
              >> >"cpceRememberL oginCookie=" +
              >> >((document.get Page1.rememberL ogin.checked) ?
              >> >document.getPa ge1.rememberLog in.value : "") +
              >> >"; expires=Thr,01-Jan-2015 00:00:00 GMT" +
              >> >"; path=/";
              >> >
              >> >http://www.quirksmode.org/js/cookies.html[/color]
              >> Thanks Rob. However, I'm not sure I understand the use of "?" and[/color]
              >":" in the following:[color=green]
              >> ((document.getP age1.rememberLo gin.checked) ?[/color]
              >document.getPa ge1.rememberLog in.value : "").[color=green]
              >> Could you explain that please.
              >> Don
              >>
              >>
              >> -----------== Posted via Newsfeed.Com - Uncensored Usenet News[/color]
              >==----------[color=green]
              >> http://www.newsfeed.com The #1 Newsgroup Service in the[/color]
              >World![color=green]
              >> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19[/color]
              >Servers =-----
              >
              >Conditional operator [ (condition) ? if-true : if-false ]
              >
              >((document.get Page1.rememberL ogin.checked) ? ---> box checked?
              >document.getPa ge1.rememberLog in.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.[/color]
              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 =-----

              Comment

              • RobB

                #8
                Re: Capturing &quot;checkbox& quot; value

                Same to you Don ! :>)

                Comment

                Working...