buddy9462
asked on
Insert Cookie value into hyperlink.
First let me say I'm no expert with javascript. Resources like this may me look much better than I am. That said,
I have the following function which:
User selects a webcase (This is where the cookie is written. That works)
Is taken to a form page to capture information
Upon submission is redirected to a thank you page where they get a "Click Here" hyperlink of the webcast they chose.
The probelm is when they get to the thank you page, the hyperlink does not capture the cookie value.
Here's the javascipt:
function setCookie(cookieData){ // sets a cookie to store the path to the requested archived webcast
if (document.cookie !=""){ // first, delete all the cookies
thisCookie = document.cookie.split(";") ;
expireDate = new Date;
expireDate.setYear(expireD ate.getYea r()-1);
for (i=0; i<thisCookie.length; i++){
cookieName = thisCookie[i].split("=")[0 ];
document.cookie = cookieName+"=;expires="+ex pireDate.t oGMTString ();
}
alert(thisCookie.length+" cookies deleted");
}
expireDate = new Date;
expireDate.setYear(expireD ate.getYea r()+1);
document.cookie = "thePath="+cookieData+";ex pires="+ex pireDate.t oGMTString ();
alert("set cookie: "+document.cookie);
}
function readCookie(){ // reads a cookie
alert("cookie="+document.c ookie);
if (document.cookie != ""){
return document.cookie.split("=") [1];
}
}
function playMedia(){ // reads the stored path to the recorded webcast and plays it in a popup window
var thePath = readCookie();
alert(thePath);
theWindow = NewWindow(thePath, 'videohi','800','688','no' );
}
function playWebcast(thePath){
theWindow = NewWindow(thePath, 'videohi','800','688','no' );
}
function clearInput(id) {
field = document.getElementById(id );
field.value = "";
}
Any ideas. All I get in the hyperlink is: <a href="javascript:playMedia ();">here< /a>
I have the following function which:
User selects a webcase (This is where the cookie is written. That works)
Is taken to a form page to capture information
Upon submission is redirected to a thank you page where they get a "Click Here" hyperlink of the webcast they chose.
The probelm is when they get to the thank you page, the hyperlink does not capture the cookie value.
Here's the javascipt:
function setCookie(cookieData){ // sets a cookie to store the path to the requested archived webcast
if (document.cookie !=""){ // first, delete all the cookies
thisCookie = document.cookie.split(";")
expireDate = new Date;
expireDate.setYear(expireD
for (i=0; i<thisCookie.length; i++){
cookieName = thisCookie[i].split("=")[0
document.cookie = cookieName+"=;expires="+ex
}
alert(thisCookie.length+" cookies deleted");
}
expireDate = new Date;
expireDate.setYear(expireD
document.cookie = "thePath="+cookieData+";ex
alert("set cookie: "+document.cookie);
}
function readCookie(){ // reads a cookie
alert("cookie="+document.c
if (document.cookie != ""){
return document.cookie.split("=")
}
}
function playMedia(){ // reads the stored path to the recorded webcast and plays it in a popup window
var thePath = readCookie();
alert(thePath);
theWindow = NewWindow(thePath, 'videohi','800','688','no'
}
function playWebcast(thePath){
theWindow = NewWindow(thePath, 'videohi','800','688','no'
}
function clearInput(id) {
field = document.getElementById(id
field.value = "";
}
Any ideas. All I get in the hyperlink is: <a href="javascript:playMedia
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome.