SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    populate hidden field with cookie

    Hi All

    Im trying to populate 2 textboxes with 2 cookies using the code below

    <html>
    <head>
    <script src="cookies.js" language="javascript"></script>
    <script language="javascript">
    var loginName = getCookie("Username");
    var loginPWD = getCookie("PWD");

    document.write(loginName + "<br>")
    document.write(loginPWD)

    </script>
    </head>
    <body>
    <script language="javascript">
    document.form.ID.value = loginName;
    document.form.PW.value = loginPWD;
    </script>
    <form name="form" method="post" action="http://flights.jtaonline.co.uk/tc.dll?ac=logon&tid=jtafvext">
    <input type="hidden" name="btn" value="Enter as Member">
    <input type="hidden" name="this" value="logonp.htm">
    <input type="hidden" name="next" value="AirStep1Return.htm">
    <input type="text" name="ID">
    <input type="text" name="PW">
    </form>
    </body>
    </html>

    The page displays the cookies with the document.write statements but will not populate the text boxes juest get the error

    document.form.ID is null or not an object

    Any help appreciated

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script language="javascript">
    document.form.ID.value = loginName;
    document.form.PW.value = loginPWD;
    </script>
    Put that below the form.
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks code working a treat now


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •