Need help prefilling input field usin JS

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

    Need help prefilling input field usin JS

    I thought I had this figured out, and have been able to do it in PHP on the server, but, how do I
    prefill an input field with a cookie value using JavaScript in a client-side page?

    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 =-----
  • McKirahan

    #2
    Re: Need help prefilling input field usin JS

    "Don" <no@adr.com> wrote in message
    news:tutds05r5s 4n5ahk515gha0fb q65ntn01c@4ax.c om...[color=blue]
    > I thought I had this figured out, and have been able to do it in PHP on[/color]
    the server, but, how do I[color=blue]
    > prefill an input field with a cookie value using JavaScript in a[/color]
    client-side page?[color=blue]
    >
    > Thanks,
    > Don[/color]

    Will this help? Watch for word-wrap.

    <html>
    <head>
    <title>coookie. htm</title>
    <script type="text/javascript">
    function coookie() {
    document.getEle mentById("data" ).value = document.cookie ;
    }
    </script>
    </head>
    <body onload="coookie ()">
    <form>
    <input type="text" name="data" size="100">
    </form>
    </body>
    </html>


    Comment

    • Don

      #3
      Re: Need help prefilling input field usin JS

      On Mon, 20 Dec 2004 16:37:40 GMT, "McKirahan" <News@McKirahan .com> wrote:
      [color=blue]
      >"Don" <no@adr.com> wrote in message
      >news:tutds05r5 s4n5ahk515gha0f bq65ntn01c@4ax. com...[color=green]
      >> I thought I had this figured out, and have been able to do it in PHP on[/color]
      >the server, but, how do I[color=green]
      >> prefill an input field with a cookie value using JavaScript in a[/color]
      >client-side page?[color=green]
      >>
      >> Thanks,
      >> Don[/color]
      >
      >Will this help? Watch for word-wrap.
      >
      ><html>
      ><head>
      ><title>coookie .htm</title>
      ><script type="text/javascript">
      >function coookie() {
      > document.getEle mentById("data" ).value = document.cookie ;
      >}
      ></script>
      ></head>
      ><body onload="coookie ()">
      ><form>
      ><input type="text" name="data" size="100">
      ></form>
      ></body>
      ></html>
      >[/color]
      Thanks McKirahan. I'll give it a try. It sure is nice knowing you're out there to help out.
      Thanks much, and have a 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

      • Don

        #4
        Re: Need help prefilling input field usin JS

        On Mon, 20 Dec 2004 16:37:40 GMT, "McKirahan" <News@McKirahan .com> wrote:
        [color=blue]
        >"Don" <no@adr.com> wrote in message
        >news:tutds05r5 s4n5ahk515gha0f bq65ntn01c@4ax. com...[color=green]
        >> I thought I had this figured out, and have been able to do it in PHP on[/color]
        >the server, but, how do I[color=green]
        >> prefill an input field with a cookie value using JavaScript in a[/color]
        >client-side page?[color=green]
        >>
        >> Thanks,
        >> Don[/color]
        >
        >Will this help? Watch for word-wrap.
        >
        ><html>
        ><head>
        ><title>coookie .htm</title>
        ><script type="text/javascript">
        >function coookie() {
        > document.getEle mentById("data" ).value = document.cookie ;
        >}
        ></script>
        ></head>
        ><body onload="coookie ()">
        ><form>
        ><input type="text" name="data" size="100">
        ></form>
        ></body>
        ></html>
        >[/color]
        McKirahan,

        I tried your suggestion, and it works just great with IE. But can't seem to get any prefill with
        Netscape. Doesn't Netscape allow prefills?

        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

        • McKirahan

          #5
          Re: Need help prefilling input field usin JS

          "Don" <no@adr.com> wrote in message
          news:gfofs0t87h 324rmjmr6ki7pur s4m0bg3u0@4ax.c om...

          [snip]
          [color=blue]
          > McKirahan,
          >
          > I tried your suggestion, and it works just great with IE. But can't seem[/color]
          to get any prefill with[color=blue]
          > Netscape. Doesn't Netscape allow prefills?
          >
          > Thanks,
          > Don[/color]

          Change
          document.getEle mentById("data" ).value = what;
          to
          document.forms[0].data.value = what;

          What version of NS are you running?

          I don't know when getElementById( ) was supported.


          Comment

          • McKirahan

            #6
            Re: Need help prefilling input field usin JS

            "McKirahan" <News@McKirahan .com> wrote in message
            news:8wTxd.2331 49$V41.22654@at tbi_s52...[color=blue]
            > "Don" <no@adr.com> wrote in message
            > news:gfofs0t87h 324rmjmr6ki7pur s4m0bg3u0@4ax.c om...
            >
            > [snip]
            >[color=green]
            > > McKirahan,
            > >
            > > I tried your suggestion, and it works just great with IE. But can't[/color][/color]
            seem[color=blue]
            > to get any prefill with[color=green]
            > > Netscape. Doesn't Netscape allow prefills?
            > >
            > > Thanks,
            > > Don[/color]
            >
            > Change
            > document.getEle mentById("data" ).value = what;
            > to
            > document.forms[0].data.value = what;
            >
            > What version of NS are you running?
            >
            > I don't know when getElementById( ) was supported.
            >
            >[/color]

            I meant, change
            document.getEle mentById("data" ).value = document.cookie ;
            to
            document.forms[0].data.value = document.cookie ;


            Comment

            • Michael Winter

              #7
              Re: Need help prefilling input field usin JS

              On Tue, 21 Dec 2004 11:09:56 GMT, McKirahan <News@McKirahan .com> wrote:

              [snip]

              [To Don:][color=blue]
              > What version of NS are you running?[/color]

              It wouldn't matter.

              As I've said to you a couple of times in the past, document.getEle mentById
              is *NOT* - I repeat, *NOT* - allowed to return elements that have a
              matching name. IE, if you haven't noticed by now, is not a browser that
              should be used for primary testing of Web documents. It's too lenient - a
              very bad thing in my opinion.

              If you need to retrieve elements document-wide based on their names, use
              the document.getEle mentsByName method. Alternatively, use the forms and
              elements collection, which I think is always preferable when accessing a
              form control within a form.

              [snip]

              Mike

              --
              Michael Winter
              Replace ".invalid" with ".uk" to reply by e-mail.

              Comment

              • Don

                #8
                Re: Need help prefilling input field usin JS

                On Tue, 21 Dec 2004 11:59:20 GMT, "McKirahan" <News@McKirahan .com> wrote:
                [color=blue]
                >"McKirahan" <News@McKirahan .com> wrote in message
                >news:8wTxd.233 149$V41.22654@a ttbi_s52...[color=green]
                >> "Don" <no@adr.com> wrote in message
                >> news:gfofs0t87h 324rmjmr6ki7pur s4m0bg3u0@4ax.c om...
                >>
                >> [snip]
                >>[color=darkred]
                >> > McKirahan,
                >> >
                >> > I tried your suggestion, and it works just great with IE. But can't[/color][/color]
                >seem[color=green]
                >> to get any prefill with[color=darkred]
                >> > Netscape. Doesn't Netscape allow prefills?
                >> >
                >> > Thanks,
                >> > Don[/color]
                >>
                >> Change
                >> document.getEle mentById("data" ).value = what;
                >> to
                >> document.forms[0].data.value = what;
                >>
                >> What version of NS are you running?
                >>
                >> I don't know when getElementById( ) was supported.
                >>
                >>[/color]
                >
                >I meant, change
                > document.getEle mentById("data" ).value = document.cookie ;
                >to
                > document.forms[0].data.value = document.cookie ;
                >[/color]
                Great! That did it. Thanks much McKirahan.
                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

                • Don

                  #9
                  Re: Need help prefilling input field usin JS

                  BTW, I'm running Netscape 7.2
                  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

                  • McKirahan

                    #10
                    Re: Need help prefilling input field usin JS

                    "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
                    news:opsjcz14iy x13kvk@atlantis ...[color=blue]
                    > On Tue, 21 Dec 2004 11:09:56 GMT, McKirahan <News@McKirahan .com> wrote:
                    >
                    > [snip]
                    >
                    > [To Don:][color=green]
                    > > What version of NS are you running?[/color]
                    >
                    > It wouldn't matter.
                    >
                    > As I've said to you a couple of times in the past, document.getEle mentById
                    > is *NOT* - I repeat, *NOT* - allowed to return elements that have a
                    > matching name. IE, if you haven't noticed by now, is not a browser that
                    > should be used for primary testing of Web documents. It's too lenient - a
                    > very bad thing in my opinion.
                    >
                    > If you need to retrieve elements document-wide based on their names, use
                    > the document.getEle mentsByName method. Alternatively, use the forms and
                    > elements collection, which I think is always preferable when accessing a
                    > form control within a form.
                    >
                    > [snip]
                    >
                    > Mike
                    >
                    > --
                    > Michael Winter
                    > Replace ".invalid" with ".uk" to reply by e-mail.[/color]

                    Mike,

                    The rules keep changing and it's hard to keep up.

                    Can you point me to some good documentation regarding
                    document.getEle mentsById
                    and
                    document.getEle mentsByName
                    usage? Thanks.


                    Comment

                    • Michael Winter

                      #11
                      Re: Need help prefilling input field usin JS

                      On Tue, 21 Dec 2004 14:25:48 GMT, McKirahan <News@McKirahan .com> wrote:

                      [snip]
                      [color=blue]
                      > Can you point me to some good documentation[/color]

                      I find that the W3C DOM specifications
                      <URL:http://www.w3.org/DOM/DOMTR.html#DOML 2> are fine. It just takes a
                      little while to get used to how the information is presented. Navigation,
                      especially within the PDFs, can be a pain, though. Alternatively, the
                      (incomplete) documentation provided by Mozilla
                      <URL:http://www.mozilla.org/docs/dom/domref> also gives an accurate
                      account of the specification and is slightly more readable.

                      I'm afraid that as I've never needed to read other sources, I can't give
                      you any. There's always Google.

                      The only other suggestion is to use another browser if you can. Both
                      Mozilla (Suite and Firefox) and Opera are free (and quite small), and
                      conform to the various specifications much better than IE probably ever
                      will[1].
                      [color=blue]
                      > regarding
                      > document.getEle mentsById[/color]

                      <URL:http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-getElBId>
                      <URL:http://www.mozilla.org/docs/dom/domref/dom_doc_ref48.h tml#1025944>
                      [color=blue]
                      > and
                      > document.getEle mentsByName[/color]

                      <URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259>
                      <URL:http://www.mozilla.org/docs/dom/domref/dom_doc_ref49.h tml#1025973>

                      [snip]

                      Mike


                      [1] After all, now that it's introduced erroneous behaviour that I have no
                      doubt authors have used (and will continue to), Microsoft will have to
                      supporting it in future versions.

                      --
                      Michael Winter
                      Replace ".invalid" with ".uk" to reply by e-mail.

                      Comment

                      Working...