Forum Moderators: open
Here is what I want to do:
1. partners send traffic to my site with an assigned ID. www.mysite.com?id=1234
this page is an html page with product selections.
I want to automatically set a cookie that will capture my partners id: "1234"
2. The subsequent pages will be a multipage cgi form where they will enter their product selection and shipping information, etc.
I want to pull the id "1234" from the cookie and add it to a hidden
field on this page called "id" so when I submit the form the ID is
captured with the sale.
3. Below is the original code I have been trying to work with,
"actually butchering". This is the bare bones original script taken from a tutorial page. It sets the cookie when a form is clicked. I want to do it on page load. I can not even get that correct.
4. If someone is the mood to offer some help I think the elements are contained below I just do not know how to edit and arrange them so they can perform the function I described.
setting the cookie:
<SCRIPT LANGUAGE="JavaScript">
cookie_name = "dataCookie";
var YouEntered;
function putCookie() {
if(document.cookie!= document.cookie)
{index = document.cookie.indexOf(cookie_name);}
else
{ index = -1;}
if (index == -1)
{
YouEntered=document.cf.cfd.value;
document.cookie=cookie_name+"="+YouEntered+"; expires=Monday, 04-Apr-2010 05:00:00 GMT";
}
}
</SCRIPT>
Retrieving the cookie:
<SCRIPT LANGUAGE="JavaScript">
cookie_name = "dataCookie";
var YouWrote;
function getName() {
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index!= -1)
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}
YouWrote = document.cookie.substring(namestart, nameend);
return YouWrote;
}
}
}
YouWrote=getName();
if (YouWrote == "dataCookie")
{YouWrote = "Nothing_Entered"}
</SCRIPT>
<SCRIPT LANGUAGE="javascript">
document.write("You Entered " +YouWrote+ ".");
</SCRIPT>
<SCRIPT LANGUAGE="javascript">
document.write("<FORM>")
document.write("You Entered:")
document.write("<INPUT TYPE=text SIZE=30 VALUE=" +YouWrote+ ">");
document.write("</FORM>")
</SCRIPT>