...

View Full Version : Help required passing data across a hyperlink



Gormless Git
10-30-2005, 08:58 PM
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

Lerura
10-30-2005, 10:13 PM
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

mlseim
10-30-2005, 11:57 PM
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.

SteelValor
10-31-2005, 04:27 PM
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.

Coastal Web
11-03-2005, 03:28 PM
I think the most logical way to go about this, would be to use PHP.

Samantha Gram

VortexCortex
11-05-2005, 12:50 AM
Save this code as pass.html

<html>
<head><title>Pass!</title></head>
<body>
<form action="catch.html" method="get">
Item: 789012<br />
<input type="hidden" name="I" value="789012"/>
<input type="submit" value="Buy" />
</form>
Item: 123456<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

<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.

:thumbsup: Good Luck.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum