Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help required passing data across a hyperlink

    Hi,

    I have a small homebrewed website that I built with FrontPage.

    I have the main site which sits on the open server and then a coupl eof secure pages which sit on a secure server for collecting credit card info.

    I want a user to be able to click a "buy this item" hyperlink which takes them from the main site into the secure area and when the newe page opens that the first box of the transaction form is automatically populated with the article number of the item they are buying.

    So, my question is "how can the article number of the item (which is unique - one item, one article number - only one for sale) be passed to the purchase order form without the user having to enter it themselves?"

    Any advice would be greatly appreciated.
    Thanks
    Andy

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    947
    Thanks
    0
    Thanked 130 Times in 129 Posts
    you can use a location.search:
    E.g:
    if you item-ID e.g is 345.
    then use nextpage.htm?345
    by
    location.href='nextpage.htm?'+Item_ID;
    and then call:

    if (location.search){
    LS=location.search;
    passedValue=LS.substring(1;LS.length);
    }

    in nextpage.htm

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,537
    Thanks
    8
    Thanked 1,092 Times in 1,083 Posts
    Another method would be to use Javascripting to write cookies.

    Those cookies can be read on any other pages and remain active
    until the user closes their browser.

    You'll have to search for: Javascript Cookies Tutorial
    ... or visit the Javascript portion of this forum.
    There's tons of them, including this one:
    http://www.netspade.com/articles/javascript/cookies.xml

    Here's more info on the "location.search" that Lelura mentioned:
    http://javascriptkit.com/javatutors/send1.shtml

    I sort of like cookies because they are retained even if the
    visitor goes off your site and comes back again.

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Location
    NYgamers.net
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Gormless Git
    Hi,

    I have a small homebrewed website that I built with FrontPage.

    I have the main site which sits on the open server and then a coupl eof secure pages which sit on a secure server for collecting credit card info.

    I want a user to be able to click a "buy this item" hyperlink which takes them from the main site into the secure area and when the newe page opens that the first box of the transaction form is automatically populated with the article number of the item they are buying.

    So, my question is "how can the article number of the item (which is unique - one item, one article number - only one for sale) be passed to the purchase order form without the user having to enter it themselves?"

    Any advice would be greatly appreciated.
    Thanks
    Andy
    * Security Note *
    Make sure that you only allow numeric data on the other side AND you never reveale your database names in your code.

  • #5
    Regular Coder Coastal Web's Avatar
    Join Date
    Oct 2004
    Posts
    225
    Thanks
    12
    Thanked 3 Times in 3 Posts
    I think the most logical way to go about this, would be to use PHP.

    Samantha Gram

  • #6
    Regular Coder
    Join Date
    May 2005
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Example using javascript.

    Save this code as pass.html
    PHP Code:
    <html>
    <
    head><title>Pass!</title></head>
    <
    body>
    <
    form action="catch.html" method="get">
    Item789012<br />
    <
    input type="hidden" name="I" value="789012"/>
    <
    input type="submit" value="Buy" />
    </
    form>
    Item123456<br />
    <
    a href="catch.html?I=123456">Buy this item</a><br /><br />
    <
    form action="catch.html" method="get">
    Enter your own item number.<br />
    Item: <input type="text" size="10" name="I"/>
    <
    input type="submit" value="Buy" />
    </
    form>
    </
    body>
    </
    html
    Save this code as catch.html
    PHP Code:
    <html><head><title>Catch!</title>
    <
    script type="text/javascript"><!--
    onload=function(){//After the page has loaded
        
    var query location.search//get the query part of the location
        //find our part of the query with a regular expression
        
    var result query.match(/I=.+[&]/);
        if (
    result == null){result query.match(/I=.+$/);}
        if (
    result == null){ //if no result, default to empty string.
            
    result="";
        } else {
            
    result result[0].match(/d+/)[0]; //pull out the digits.
        
    }
        
    document.getElementById("item").value result//get the text field, and assign a value.
    }
    //--></script>
    </head>
    <
    body>
    <
    form action="checkout.html" method="get">
    Item Number: <input type="text" size="10" id="item"/><br/>
    <
    input type="submit" value="Purchase"/>
    </
    form></body></html
    Make sure both files are in the same folder, then point your web browser at pass.html

    This example shows 3 ways to pass the value of the item number...
    1. A form with a hidden input element.
    2. An anchor link with a hardcoded query.
    3. A form with a normal input element.

    I know what it's like, and sometimes you just need a working example.

    Good Luck.
    Last edited by VortexCortex; 11-05-2005 at 02:10 AM.


  •  

    Posting Permissions

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