i have a code at the following address in progress: [URL=http://www.gooba.tk/]www.gooba.tk[/URL] . it uses cookies to store your favourite links in a list for future refference. Now when you use the favourites list, if you add more than 10 or 11 links for some reason they all dissappear and do all sorts of stupid things. why? i hav spent ages trying to fix it but cannot see where the problem is.
i am not asking you to fix it just push me in the correct direction please..
@David_HarrisonMar 24.2004 — #I think there is a limit to the number of cookies a user can have on their PC. Instead of creating lots of cookies, create 1 cookie with all of the URL's in. When the URL's are received by the function just do something like this:
<i> </i> var cookieString; var urls=new Array(); urls["href"]=new Array(); urls["text"]=new Array();
function favAdd(){
var newHref=document.forms.favForm.favHrefInput.value; var newText=document.forms.favForm.favTextInput.value;
if (newHref.length==0) {alert("Please enter the URL (address) of the website."); return false;} if (newHref.substring(0, 7)!="http://") newHref="http://"+newHref; if (newText.length==0) newText=newHref.substring(7, newHref.length); if (newText.length>50) newText=newText.substring(0, 49)+"...";
What the above scripts do is combine all of href's into one array and all of the text's in another array.
When the information is stored in a cookie each array is joined into a single string and each item is separated by "::delim::" then the to arrays are joined together and separated by "::spacer::".
When separating the information out into different arrays again, I have in effect just reversed the process. If you like I could write an actual working script in an HTML document that joins arrays and splits them up again, then you can add the cookie part of the script.