I have a webpage that includes a map of the U.S. and for each state I have a menu to different city websites for each state. What I would like to do is once a visitor clicks on one of the city links, a cookie is created so that when that user returns to my website, he is taken directly to the city he selected, not the home page again.
I have a script that I am working on but I am getting errors with it. I was hoping someone here could help me. I am not a developer and know very little about scripting, so any ideas or advice are helpful.
Here is the script in the HEAD section of my page:
Code:
<SCRIPT type='text/javascript'>
function setCookie(c_name, value, expiredays)
{
var exdate = new Date();
exdate.setDate(exdate.getDate() + expiredays);
document.cookie=c_name + "=" + escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
function GetDocsInCity()
{
var mylist = document.getElementById("myList");
var myCity = mylist.values[mylist.selectedIndex].text;
setCookie('myCity',myCity,365)
var url = "http://fleabay.net/";
document.location.href = url + myCity;
}