Hi:
I need some help,
I have a form on one of my pages and I need to save the information the user inputs, submit the form via e-mail and redirected to a thank you page.
What I have done is set a JavaScript cookie in order to re populate the fields when the user comes back to that form.
well the cookie is only set if I do not submit the form via e-mail (with a cgi).
Can anyone help me, I do not know cgi, pearl or asp which have been some of the suggestions given.
**************************************************
Please help, I need to have it up as soon as possible, my job depends on it.
**************************************************
The attach code is partial so you can see how I coded, if you need the full source let me know.
************************************************************
<HTML>
<HEAD>
// ***********************************************************************************
// *************************** GET COOKIE ********************************************
// ***********************************************************************************
function Get_Cookie(name) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length)))
return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
// ***********************************************************************************
// *********************** SET COOKIE ************************************************
// ***********************************************************************************
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
// ***********************************************************************************
// *********************** SET UP FORM ***********************************************
// ***********************************************************************************
function setupForm() {
if (userProfile) getValues(userProfile);
}
// ***********************************************************************************
// ************************ GET VALUES *********************************************
// ***********************************************************************************
function getValues(string) {
getValue(string,"Contact_Name", document.profileForm.Contact_Name, "text");
getValue(string,"Contact_Company", document.profileForm.Contact_Company, "text");
getValue(string,"Contact_Position", document.profileForm.Contact_Position, "text");
getValue(string,"Contact_Address", document.profileForm.Contact_Address, "text");
getValue(string,"Contact_City_State_Province", document.profileForm.Contact_City_State_Province, "text");
getValue(string,"Contact_Postal_Code", document.profileForm.Contact_Postal_Code, "text");
getValue(string,"Contact_Other_Country", document.profileForm.Contact_Other_Country, "text");
getValue(string,"MSDS_BrandName", document.profileForm.MSDS_BrandName, "text");
getValue(string,"MSDS_GradeName", document.profileForm.MSDS_GradeName, "text");
getValue(string,"Contact_Telephone", document.profileForm.Contact_Telephone, "text");
getValue(string,"Contact_Fax", document.profileForm.Contact_Fax, "text");
getValue(string,"Contact_Email", document.profileForm.Contact_Email, "text");
getValue(string,"Contact_Comments", document.profileForm.Contact_Comments, "textarea");
//getValue(string,"Contact_Country", document.profileForm.Contact_Country, "select");
//getValue(string,"Contact_Industry", document.profileForm.Contact_Industry, "select");
//getValue(string,"Contact_Method", document.profileForm.Contact_Method, "select");
//getValue(string,"Contact_Urgency", document.profileForm.Contact_Urgency, "select");
//getValue(string,"Contact_Language", document.profileForm.Contact_Language, "radio");
}
// ***********************************************************************************
// *********************** REPLACE **************************************************
// ***********************************************************************************
function replace(string,text,by) {// Replaces text with by in string
var i = string.indexOf(text);
var newstr = '';
if ((!i) || (i == -1)) return string;
newstr += string.substring(0,i) + by;
if (i+text.length < string.length)
newstr += replace(string.substring(i+text.length,string.length),text,by);
return newstr;
}
// ***********************************************************************************
// ********************* GET VALUE *************************************************
// ***********************************************************************************
function getValue(string,elementName,object,elementType) {// gets value of elementName from string and populates object of elementType
var startPos = string.indexOf(elementName + "=")
if (startPos > -1) {
startPos = startPos + elementName.length + 1;
var endPos = string.indexOf("&",startPos);
if (endPos == -1) endPos = string.length;
var elementValue = unescape(string.substring(startPos,endPos));
if (elementType == "text") object.value = elementValue;
//if (elementType == "password") object.value = elementValue;
//if (elementType == "select") object.selectedIndex = elementValue;
//if (elementType == "checkbox") object.checked = onCheck(elementValue);
//if (elementType == "radio") object[elementValue].checked = true;
if (elementType == "textarea") object.value = elementValue;
}
}
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" " onLoad="setupForm();" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0" LINK="#004E5F" VLINK="#999999" ALINK="#006666">
<!-- This is the script for the user profile -->
<SCRIPT LANGUAGE="JavaScript">
<!--
var today = new Date();
// var expires = new Date(today.getTime() + (86400000)); // 86400000 = 1 day or 60 * 60 * 24
var expires = new Date(today.getTime() + (1 * 86400000));
//var searchString = replace(self.location.search.substring(1),"+"," ");
//if (searchString.length > 0)
Set_Cookie("userProfile",searchString,expires);
var userProfile = Get_Cookie("userProfile");
//-->
</SCRIPT>
<!-- use this form heading for testing only -->
<FORM NAME="profileForm" onSubmit="return checkForm(this);" method="POST" action="mailto: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->"-->
<!--FORM NAME="profileForm" onSubmit="return checkForm(this);" METHOD="POST" ACTION="http://www.nutraceuticalsworld.com/cgi-shl/formmail.pl"-->
<!--INPUT type="HIDDEN" NAME="sort" value="order:Contact_Name, Contact_Position, Contact_Company, Contact_Telephone,Contact_Fax, Contact_Address,Contact_City_State_Province,Contact_Postal_Code,Country,Contact_Email,Contact_Assist ance_Type,Contact_Comments"-->
<!--input type="HIDDEN" name="recipient" value="[email protected]"-->
<!--INPUT TYPE=HIDDEN NAME=recipient VALUE="[email protected],[email protected],cont <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->" -->
<!-- INPUT type="HIDDEN" name="redirect" value="http://www.nutraceuticalsworld.com/MSDS_contact-thankyou.htm" -->
<!--input type="HIDDEN" NAME="email" value="[email protected]"-->
<INPUT TYPE="HIDDEN" NAME="Form" VALUE = "" >
<INPUT TYPE="HIDDEN" NAME="Subject" VALUE="" >
<INPUT TYPE="HIDDEN" NAME="Requested_MSDS" VALUE="">
I need some help,
I have a form on one of my pages and I need to save the information the user inputs, submit the form via e-mail and redirected to a thank you page.
What I have done is set a JavaScript cookie in order to re populate the fields when the user comes back to that form.
well the cookie is only set if I do not submit the form via e-mail (with a cgi).
Can anyone help me, I do not know cgi, pearl or asp which have been some of the suggestions given.
**************************************************
Please help, I need to have it up as soon as possible, my job depends on it.
**************************************************
The attach code is partial so you can see how I coded, if you need the full source let me know.
************************************************************
<HTML>
<HEAD>
// ***********************************************************************************
// *************************** GET COOKIE ********************************************
// ***********************************************************************************
function Get_Cookie(name) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length)))
return null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
// ***********************************************************************************
// *********************** SET COOKIE ************************************************
// ***********************************************************************************
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
// ***********************************************************************************
// *********************** SET UP FORM ***********************************************
// ***********************************************************************************
function setupForm() {
if (userProfile) getValues(userProfile);
}
// ***********************************************************************************
// ************************ GET VALUES *********************************************
// ***********************************************************************************
function getValues(string) {
getValue(string,"Contact_Name", document.profileForm.Contact_Name, "text");
getValue(string,"Contact_Company", document.profileForm.Contact_Company, "text");
getValue(string,"Contact_Position", document.profileForm.Contact_Position, "text");
getValue(string,"Contact_Address", document.profileForm.Contact_Address, "text");
getValue(string,"Contact_City_State_Province", document.profileForm.Contact_City_State_Province, "text");
getValue(string,"Contact_Postal_Code", document.profileForm.Contact_Postal_Code, "text");
getValue(string,"Contact_Other_Country", document.profileForm.Contact_Other_Country, "text");
getValue(string,"MSDS_BrandName", document.profileForm.MSDS_BrandName, "text");
getValue(string,"MSDS_GradeName", document.profileForm.MSDS_GradeName, "text");
getValue(string,"Contact_Telephone", document.profileForm.Contact_Telephone, "text");
getValue(string,"Contact_Fax", document.profileForm.Contact_Fax, "text");
getValue(string,"Contact_Email", document.profileForm.Contact_Email, "text");
getValue(string,"Contact_Comments", document.profileForm.Contact_Comments, "textarea");
//getValue(string,"Contact_Country", document.profileForm.Contact_Country, "select");
//getValue(string,"Contact_Industry", document.profileForm.Contact_Industry, "select");
//getValue(string,"Contact_Method", document.profileForm.Contact_Method, "select");
//getValue(string,"Contact_Urgency", document.profileForm.Contact_Urgency, "select");
//getValue(string,"Contact_Language", document.profileForm.Contact_Language, "radio");
}
// ***********************************************************************************
// *********************** REPLACE **************************************************
// ***********************************************************************************
function replace(string,text,by) {// Replaces text with by in string
var i = string.indexOf(text);
var newstr = '';
if ((!i) || (i == -1)) return string;
newstr += string.substring(0,i) + by;
if (i+text.length < string.length)
newstr += replace(string.substring(i+text.length,string.length),text,by);
return newstr;
}
// ***********************************************************************************
// ********************* GET VALUE *************************************************
// ***********************************************************************************
function getValue(string,elementName,object,elementType) {// gets value of elementName from string and populates object of elementType
var startPos = string.indexOf(elementName + "=")
if (startPos > -1) {
startPos = startPos + elementName.length + 1;
var endPos = string.indexOf("&",startPos);
if (endPos == -1) endPos = string.length;
var elementValue = unescape(string.substring(startPos,endPos));
if (elementType == "text") object.value = elementValue;
//if (elementType == "password") object.value = elementValue;
//if (elementType == "select") object.selectedIndex = elementValue;
//if (elementType == "checkbox") object.checked = onCheck(elementValue);
//if (elementType == "radio") object[elementValue].checked = true;
if (elementType == "textarea") object.value = elementValue;
}
}
//-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" " onLoad="setupForm();" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0" LINK="#004E5F" VLINK="#999999" ALINK="#006666">
<!-- This is the script for the user profile -->
<SCRIPT LANGUAGE="JavaScript">
<!--
var today = new Date();
// var expires = new Date(today.getTime() + (86400000)); // 86400000 = 1 day or 60 * 60 * 24
var expires = new Date(today.getTime() + (1 * 86400000));
//var searchString = replace(self.location.search.substring(1),"+"," ");
//if (searchString.length > 0)
Set_Cookie("userProfile",searchString,expires);
var userProfile = Get_Cookie("userProfile");
//-->
</SCRIPT>
<!-- use this form heading for testing only -->
<FORM NAME="profileForm" onSubmit="return checkForm(this);" method="POST" action="mailto: <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->"-->
<!--FORM NAME="profileForm" onSubmit="return checkForm(this);" METHOD="POST" ACTION="http://www.nutraceuticalsworld.com/cgi-shl/formmail.pl"-->
<!--INPUT type="HIDDEN" NAME="sort" value="order:Contact_Name, Contact_Position, Contact_Company, Contact_Telephone,Contact_Fax, Contact_Address,Contact_City_State_Province,Contact_Postal_Code,Country,Contact_Email,Contact_Assist ance_Type,Contact_Comments"-->
<!--input type="HIDDEN" name="recipient" value="[email protected]"-->
<!--INPUT TYPE=HIDDEN NAME=recipient VALUE="[email protected],[email protected],cont <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->" -->
<!-- INPUT type="HIDDEN" name="redirect" value="http://www.nutraceuticalsworld.com/MSDS_contact-thankyou.htm" -->
<!--input type="HIDDEN" NAME="email" value="[email protected]"-->
<INPUT TYPE="HIDDEN" NAME="Form" VALUE = "" >
<INPUT TYPE="HIDDEN" NAME="Subject" VALUE="" >
<INPUT TYPE="HIDDEN" NAME="Requested_MSDS" VALUE="">