Link to home
Start Free TrialLog in
Avatar of buddy9462
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(expireDate.getYear()-1);
            for (i=0; i<thisCookie.length; i++){
                  cookieName = thisCookie[i].split("=")[0];
                  document.cookie = cookieName+"=;expires="+expireDate.toGMTString();
            }
      alert(thisCookie.length+" cookies deleted");
      }
      expireDate = new Date;
      expireDate.setYear(expireDate.getYear()+1);
      document.cookie = "thePath="+cookieData+";expires="+expireDate.toGMTString();
      alert("set cookie: "+document.cookie);
}

function readCookie(){ // reads a cookie
alert("cookie="+document.cookie);
      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>
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You are welcome.