surreal5335
New Member
- Messages
- 28
- Reaction score
- 0
- Points
- 0
I am in the process of creating an email submit button, I have my php code debugged, but I am trying to add a thank you page with a cookie attatched so as to thank the client by name entered in the name field.
I have the code JS for it here:
I am also not sure where to put in the link to this thank you page on the email form:
Lastly if this is part of the issue here is the code for the first part of the cookie on the email form:
Thanks a lot for your help
I have the code JS for it here:
Code:
<title>Thank you for your submission</title>
<script type="text/javascript" language="JavaScript">
var Cookies = new Array(); // Leave this line as is.
function ReadCookieValues() {
var CookieName = "emailcookie";
var cookiecontent = '';
if(document.cookie.length > 0) {
var cookiename = emailform + '=';
var cookiebegin = document.cookie.indexOf(emailform);
var cookieend = 0;
if(cookiebegin > -1) {
cookiebegin += cookiename.length;
cookieend = document.cookie.indexOf(";",cookiebegin);
if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
cookiecontent = document.cookie.substring(cookiebegin,cookieend);
}
}
if(cookiecontent.length < 0) { return; }
cookiecontent = unescape(cookiecontent);
Cookies = cookiecontent.split("\t\t");
}
ReadCookieValues();
function GetFieldValue(n) {
for( var i = 0; i < Cookies.length; i++) {
var nv = Cookies[i].split("\t");
if(nv[0] == n) {
if(nv[1].length > 0) { return nv[1]; }
else { return ''; }
}
}
return '';
}
function PrintPersonalizednfo() {
var otherwise = '';
var append = '';
if(arguments.length < 1) { return; }
if(arguments.length > 1) { otherwise = arguments[1]; }
if(arguments.length > 2) { append = arguments[2]; }
var v = GetFieldValue(arguments[0]);
if(v.length == 0) { v = otherwise; }
document.write(v+append);
}
//-->
</script>
<p>
<noscript>
Thank you for contacting me, I will get back to you as soon I am available
</noscript>
Code:
[B]<img src="http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/portfolioheader.png" hspace="10" vspace="10" align="center">[/B][B]<br/>[/B][B]<br>[/B]
[B][U]<form method="post" name="emailform" action="emailform.php">[/U][/B]
[B]<p class="legend">[/B]Contact via email[B]</p>[/B]
[B]<fieldset id="conact">[/B]
[B][U]<[I]label[/I]>[/U][/B]Name: [B][U]</[I]label[/I]>[/U][/B][B][U]<input type="text" name="name" size="30"/>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<[I]label[/I]>[/U][/B]Email: [B][U]</[I]label[/I]>[/U][/B][B][U]<input type="text" name="emailaddr1" size="30"/>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<[I]label[/I]>[/U][/B]Email: [B][U]</[I]label[/I]>[/U][/B][B][U]<input type="text" name="emailaddr2" size="30"/>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<[I]label[/I]>[/U][/B]Phone: [B][U]</[I]label[/I]>[/U][/B][B][U]<input type="text" name="phone" size="30"/>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<[I]label[/I]>[/U][/B]Comments: [B][U]</[I]label[/I]>[/U][/B][B]<br>[/B][B][U]<textarea name="comments" rows="10" cols="30">[/U][/B]Please give me a brief description of the work you need done[B][U]</textarea>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<input type="submit" name="submit">[/U][/B][B][U]</button>[/U][/B][B]<br/>[/B]
Code:
[B][B]<script type="text/javascript" language="JavaScript">[/B][/B]
//thank you page cookie
[I]function[/I] CookieTheValues() {
[I]var[/I] FormName = "emailform";
[I]var[/I] CookieName = "emailcookie";
[I]var[/I] cookiestring = [I]new[/I] Array();
[I]var[/I] ilen = eval('[I]document[/I].emailform.length');
[I]for[/I] (i = 0; i [B]< ilen; i++) {
[I]var[/I] n = eval('[I]document[/I].emailform.elements['+i+'].name');
[I]if[/I](n.length == 0) { [I]continue[/I]; }
[I]var[/I] fieldlen = eval('[I]document[/I].emailform.'+n+'.length');
[I]if[/I](fieldlen >[/B] 0) { [I]continue[/I]; }
[I]var[/I] v = eval('[I]document[/I].emailform.'+n+'.value');
[I]if[/I](v.length == 0) { [I]continue[/I]; }
v = escape(v);
cookiestring.push(n + '%09' + v);
}
[I]document[/I].cookie = CookieName + '=' + cookiestring.join('%09%09') + '; path=/';
[I]return[/I] [I]true[/I];
}
Thanks a lot for your help