the saveList() function works. I tried to write the loadList() function to repopulate the select options, but I'm obviously doing something wrong at the end of the code. In my test I save 3 items and when it repopulates it does create 3 options, however only the first option contains the proper text and value and the other 2 display undefined. Here's the code:
function saveList() {
var newList = document.amp.playlist.options;
var j, len = newList.length;
var Sngstr = "";
for (j = 0; j < len; j++) {
if (Sngstr.length > 0) Sngstr += "&";
Sngstr += newList[j].value + "|" + newList[j].text;
}
setCookie ("TheList",Sngstr,expdate);
}
function loadList() {
var i, j;
playList = document.amp.playlist.options;
TheList = getCookie("TheList"
if (TheList != null) {
listArray = TheList.split("&"
for (i = 0; i < listArray.length; i++) {
j = i + 1;
piecesArray = listArray.split("|"
//Below is where something seems to be wrong
var no = new Option();
no.value = piecesArray;
no.text = piecesArray[j];
playList[playList.length] = no;
}
}
}
Any ideas?
function saveList() {
var newList = document.amp.playlist.options;
var j, len = newList.length;
var Sngstr = "";
for (j = 0; j < len; j++) {
if (Sngstr.length > 0) Sngstr += "&";
Sngstr += newList[j].value + "|" + newList[j].text;
}
setCookie ("TheList",Sngstr,expdate);
}
function loadList() {
var i, j;
playList = document.amp.playlist.options;
TheList = getCookie("TheList"
if (TheList != null) {
listArray = TheList.split("&"
for (i = 0; i < listArray.length; i++) {
j = i + 1;
piecesArray = listArray.split("|"
//Below is where something seems to be wrong
var no = new Option();
no.value = piecesArray;
no.text = piecesArray[j];
playList[playList.length] = no;
}
}
}
Any ideas?