How do I send text on one page to a form field on the next page?

G

Guest

I am creating a webpage for a small business and I am making order forms.
Next to each item I have a button and it takes you to our order form page. I
want our customers to be able to click on that button and have the item
number automatically entered into the "Item Number" field on the order form.

Any ideas?
Thanks!
 
G

Guest

Append a query string to the link from the item page to the order page, such
as
<a href="orderpage.htm?itemid=1234">Order</a>

Add this script to the <head> section of the order page.

<script>
function qsobj (){
var qvbl;
var qstring = "" + document.location.search.substring(1);
if (qstring != ""){
var qpairs = qstring.split("&");
for (i=0; i < qpairs.length; i++) {
qvbl = qpairs.split("=");
this["" + qvbl[0]] = unescape(qvbl[1].replace("+"," "));
}
}
}
function getqsvar(qsvar){
if (qstr[qsvar] == null){
return "";
}else{
return qstr[qsvar];
}
}
var qstr = new qsobj();
</script>

Name the Item Number text box ItemNumber.

Add the following onload= attribute to your <body> tag:

<body onload="document.forms[0].ItemNumber.Value = getqsvar("itemid") ;">

However, this is going to get very ugly (and difficult) if you want to build
a shopping card with multipel items, computer order totals and shipping,
collect charge card numbers, and so forth. If you have these features in
mind, you might as well start looking for a commerical shopping cart
application now. Chances are, your host already has one or more of these
available for a reasonable fee.

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*-----------------------------­-----------------------
|\----------------------------­-----------------------
|| Microsoft Windows SharePoint Services Inside Out
|| Microsoft Office FrontPage 2003 Inside Out
||----------------------------­-----------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/----------------------------­-----------------------
*-----------------------------­-----------------------
 
G

Guest

I tried it and it didn't work :(

Maybe I'm doing something wrong? In the body onload tag do I need to change
"document" or "forms" to something specific?

Thanks,
Andrea



Jim Buyens said:
Append a query string to the link from the item page to the order page, such
as
<a href="orderpage.htm?itemid=1234">Order</a>

Add this script to the <head> section of the order page.

<script>
function qsobj (){
var qvbl;
var qstring = "" + document.location.search.substring(1);
if (qstring != ""){
var qpairs = qstring.split("&");
for (i=0; i < qpairs.length; i++) {
qvbl = qpairs.split("=");
this["" + qvbl[0]] = unescape(qvbl[1].replace("+"," "));
}
}
}
function getqsvar(qsvar){
if (qstr[qsvar] == null){
return "";
}else{
return qstr[qsvar];
}
}
var qstr = new qsobj();
</script>

Name the Item Number text box ItemNumber.

Add the following onload= attribute to your <body> tag:

<body onload="document.forms[0].ItemNumber.Value = getqsvar("itemid") ;">

However, this is going to get very ugly (and difficult) if you want to build
a shopping card with multipel items, computer order totals and shipping,
collect charge card numbers, and so forth. If you have these features in
mind, you might as well start looking for a commerical shopping cart
application now. Chances are, your host already has one or more of these
available for a reasonable fee.

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*-----------------------------­-----------------------
|\----------------------------­-----------------------
|| Microsoft Windows SharePoint Services Inside Out
|| Microsoft Office FrontPage 2003 Inside Out
||----------------------------­-----------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/----------------------------­-----------------------
*-----------------------------­-----------------------


Andrea said:
I am creating a webpage for a small business and I am making order forms.
Next to each item I have a button and it takes you to our order form page. I
want our customers to be able to click on that button and have the item
number automatically entered into the "Item Number" field on the order form.

Any ideas?
Thanks!
 
G

Guest

Sorry, the <body> tag should be:

<body onload="document.forms[0].ItemNumber.value = getqsvar('itemid') ;">

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*-----------------------------­-----------------------
|\----------------------------­-----------------------
|| Microsoft Windows SharePoint Services Inside Out
|| Microsoft Office FrontPage 2003 Inside Out
||----------------------------­-----------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/----------------------------­-----------------------
*-----------------------------­-----------------------


Jim Buyens said:
Append a query string to the link from the item page to the order page, such
as
<a href="orderpage.htm?itemid=1234">Order</a>

Add this script to the <head> section of the order page.

<script>
function qsobj (){
var qvbl;
var qstring = "" + document.location.search.substring(1);
if (qstring != ""){
var qpairs = qstring.split("&");
for (i=0; i < qpairs.length; i++) {
qvbl = qpairs.split("=");
this["" + qvbl[0]] = unescape(qvbl[1].replace("+"," "));
}
}
}
function getqsvar(qsvar){
if (qstr[qsvar] == null){
return "";
}else{
return qstr[qsvar];
}
}
var qstr = new qsobj();
</script>

Name the Item Number text box ItemNumber.

Add the following onload= attribute to your <body> tag:

<body onload="document.forms[0].ItemNumber.Value = getqsvar("itemid") ;">

However, this is going to get very ugly (and difficult) if you want to build
a shopping card with multipel items, computer order totals and shipping,
collect charge card numbers, and so forth. If you have these features in
mind, you might as well start looking for a commerical shopping cart
application now. Chances are, your host already has one or more of these
available for a reasonable fee.

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
*-----------------------------­-----------------------
|\----------------------------­-----------------------
|| Microsoft Windows SharePoint Services Inside Out
|| Microsoft Office FrontPage 2003 Inside Out
||----------------------------­-----------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/----------------------------­-----------------------
*-----------------------------­-----------------------


Andrea said:
I am creating a webpage for a small business and I am making order forms.
Next to each item I have a button and it takes you to our order form page. I
want our customers to be able to click on that button and have the item
number automatically entered into the "Item Number" field on the order form.

Any ideas?
Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top