passing data from one page to another without forms

Discussion in 'JavaScript' started by vanderberg, Mar 2, 2008.

  1. #1
    please can someone explain to me how to pass value from one page to another without forms?

    Example:
    Page1.html will pass some value to Page2.html
    Page2.html will accept and print that value


    THANK YOU!!!
     
    vanderberg, Mar 2, 2008 IP
  2. hip_hop_x

    hip_hop_x Active Member

    Messages:
    522
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #2
    in php you could do this:
    page1.html go to page2.php?name=something&other=something_else
    then in page2.php do this:
    
    <?php $name=$_GET['name'];
    $other=$_GET['other'];?>
    /* and to get those values in javascript*/
    <script>
    var name="<?php echo $name;?>";
    var other="<?php echo $other;?>";
    </script>
    
    PHP:
     
    hip_hop_x, Mar 2, 2008 IP
  3. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't recommend ever using GET variables to save session state as URL's are easily modified. Either use sessions with PHP (real simple) and populate the javascript variables on page load, or even better, just use Javascript cookies.

    BTW cookies written by PHP are readable by Javascript and vice-versa.
     
    GreatMetro, Mar 13, 2008 IP
  4. Vozzek

    Vozzek Active Member

    Messages:
    206
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    58
    #4
    You could use $_SESSION variables, but I've had some problems in the past with them getting wiped out when I needed them.

    Why would you not want to use forms? Hidden inputs are always an option.
     
    Vozzek, Mar 13, 2008 IP
  5. pointkids21

    pointkids21 Banned

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    u can copy nlng
     
    pointkids21, Mar 14, 2008 IP
  6. Namuk

    Namuk Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i think session start() will be function....
     
    Namuk, Mar 14, 2008 IP
  7. andyoudontstop

    andyoudontstop Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    What type of application are you trying to write?
     
    andyoudontstop, Jun 19, 2008 IP
  8. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #8
    In javascript, you can do it using cookies.
     
    rohan_shenoy, Jun 19, 2008 IP
  9. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Since the page is html not php, so I think session is not favored.
    2 options: using cookies or passing value through url.

    If you use passing values through url, you may need a javascript code to extract value from top.location.href
     
    koolman, Jun 19, 2008 IP