View Full Version : Resolved Featured Content Glider - tracking content viewed?

05-07-2009, 11:00 PM
1) Script Title: Featured Content Glider

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tentglider.htm

3) Describe problem:

While I am trying to research just how cookies work, I find myself thoroughly confused on how to extract values from the cookie used to keep track of which content is being viewed. Essentially I have a web tool with one input box that is typed into and submitted. I am using the content glider to offer one of two different views on the processed result. I would like to utilize the information from the cookie [which content is currently being viewed] + enter it into my database. So it would record which content view they were using at the time of hitting submit.

My working idea right now is to have two radio inputs within a hidden div... and one of them would be automatically selected based on the cookie value.

This is where I get lost... how to extract that sort of information from this cookie + how to link the selected state of a radio button to it.

Can you offer any advice? Thanks in advance for your time!


edit, I figured it out.. and now I'll explain what to do!

Soo first I read all of the cookies being captured to find out how these ones are stored, once I knew the name and value outcome- then it was creating a basic if statement.

To investigate my website cookies I used this script

<script type="text/javascript" charset="utf-8">
function GetCookie(name)
var result = null;
var myCookie = " " + document.cookie + ";";
var searchName = " " + name + "=";
var startOfCookie = myCookie.indexOf(searchName);
var endOfCookie;
if (startOfCookie != -1)
startOfCookie += searchName.length;
// skip past cookie name
endOfCookie = myCookie.indexOf(";", startOfCookie);
result = unescape(myCookie.substring(startOfCookie,endOfCookie));
return result;

* found this code here (http://www.java2s.com/Code/JavaScript/Development/ACookieExample.htm)

I then wrote a short if statement saying 'if you are on page1 do this, otherwise do that' -

<script type="text/javascript" charset="utf-8">
if (GetCookie("output_container") == '1pg'){
document.write('<input type="hidden" name="alg_view" value="02" border="0">');
} else {
document.write('<input type="hidden" name="alg_view" value="01" border="0">');

- With this placed right inside the form, it will generate the hidden input field that I needed log which page is being viewed to my database.

Hope this helps someone in the future trying to do the same.