Results 1 to 7 of 7

Thread: Passing values between html pages

  1. #1
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing values between html pages

    I'm developing a prototype website. NO server interaction or anything.
    I just want to pass the keyed in data around from HTML pg1 to HTML Pg2.
    Any ideas..

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You could use javascript to place cookies in the users browser for use on the pages. How you would pull this off, I'm not sure but maybe someone with javascript know-how could inform us both.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    u means using document.cookie??

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Perhaps, if that is the javascript way of doing it. (I'm only used to using PHP for interaction and am currently in the process of learning Javascript and AJAX.) I'm pretty sure this is the best way to do it without server side interaction.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yup, i found it. Just wonder if it can store array. v

    http://www.dynamicdrive.com/forums/s...ocument.cookie

  6. #6
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Another method for passing the values between page is as follows. you can use the HTML form field too to pass the values between pages

    The first page

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    
    <body>
    <a href='2.htm?Something=This is another method'>Click here</A>
    </body>
    </html>
    The page that gets the parameter from the first page

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    
    <body>
    <SCRIPT LANGUAGE="Javascript">
    function GetParam(name)
    {
      var start=location.search.indexOf("?"+name+"=");
      if (start<0) start=location.search.indexOf("&"+name+"=");
      if (start<0) return '';
      start += name.length+2;
      var end=location.search.indexOf("&",start)-1;
      if (end<0) end=location.search.length;
      var result=location.search.substring(start,end);
      var result='';
      for(var i=start;i<=end;i++) {
        var c=location.search.charAt(i);
        result=result+(c=='+'?' ':c);
      }
      return unescape(result);
    }
    alert(GetParam('Something'));
    </SCRIPT>
    </body>
    </html>
    
    The above mentioned Javascript can be described fully at http://www.cryer.co.uk

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Yeah. Using a variable in the address bar makes the most sense.

    I would suggest using PHP for this purpose. It's much better.

    But... javascript doesn't need a server. That is the ONLY advantage, but if you need that, then that's the only real option.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •