/    Sign up×
Community /Pin to ProfileBookmark

syntax error in my cookie jar!

can anyone tell me why line 15 is getting a syntax error.

Bear with me I know less about cookies than I did about forms. notice I said ‘did’ because I have learned so much on here lately.

[code=php]//first I need to find the cookie

function ReadCookie(wishlist) {
var theCookie=””+document.cookie;
var ind=theCookie.indexOf(wishlist);
if (ind==-1 || wishlist==””) return “”;
var ind1=theCookie.indexOf(‘;’,ind);
if (ind1==-1) ind1=theCookie.length;

}
// now I need to split it further.
var wish = theCookie.substring(ind,ind1);
wish = unescape(wish);
wishlist=wish.split(‘&’);
for(var i=);i<wishlist.length;i++){
var product+wishlist[i].split(‘:’);
var productname=product[0];
var remainder=product[1].split(‘=’);
var describe=remainder[0];
var pagelocation=remainder[1];
displayWishlist(productname,describe,pagelocation);
}

//now its split I need to create nodes and assign attributes

function displayWishlist(productname,describe,pagelocation){
var descrip=document.createTextNode(describe);
var linkString=pagelocation + ‘.html’;
var anchorSign=document.CreateElement(‘a’);
var moreDetails=document.createTextNode(‘more details’);
var words=document.createTextNode(‘click here for more’);
var lineSpace=document.createElement(‘br /);
var p+document.createElement(‘p’);
var name=document.createElement(‘span’);
var image=document.createElement(‘img’);
var srcString=”images/”+ productname = ‘.jpg’;

//now tell it where to put it all

var place=document.getElementById(‘middle’);
anchorSign.href=hrefString;
image.setAttribute(‘src’,srcString);
image.setAttribute(‘alt’,productName);
p.className=’newPara’;

anchorSign.appendChild(moreDetails);
name.appendChild(descrip);
p.appendChild(image);
p.appendChild(name)
p.appendChild(lineSpace)
p.appendChild(words)
p.appendChild(anchorSign);
place.appendChild(p);
return;

}[/code]

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@Logic_AliMay 16.2007 — can anyone tell me why line 15 is getting a syntax error.
[CODE]for(var i=);i<wishlist.length;i++){[/CODE]
[/QUOTE]
At a glance, that's the most glaringly obvious error.
Copy linkTweet thisAlerts:
@paulamcclauthorMay 16.2007 — :o At a glance, that's the most glaringly obvious error.[/QUOTE]
:o

I must have typed that line in my sleep. Didn't go to bed last night.

walked away for 10 minutes, had a coffee and hey presto that ) should be a 0

I don't suppose you know why its telling me runtime error expected ';' for line 17 when it has one.

I know! I know! its probably obvious, but I am running out of time and I am sooo tired.
Copy linkTweet thisAlerts:
@FangMay 16.2007 — An '=' maybevar product[B][COLOR="Red"]+[/COLOR][/B]wishlist[i].split(':');
Get some sleep!
Copy linkTweet thisAlerts:
@paulamcclauthorMay 16.2007 — Cheers Fang!

your'e right I need some sleep. trouble is two kids at home and an ever looming assignment deadline = no sleep yet!

have to settle for a couple of proplus pills, some omega3 and a cold shower.

Is there a tool to check javascript code like there is on HTML kit where it gives you your html errors line by line.
Copy linkTweet thisAlerts:
@paulamcclauthorMay 16.2007 — OK! no more errors, but not displaying the goods. I know I've probably missed something obvious.

I've attached the necessary files

The cookie string is stored in a [B]var[/B] in the index page.

how do I tell the external js file where it is or should it be finding it?

anyone know why its not displaying the images on the wish list page.

the pages you need to look at are

index.html(the flash wont play as ive removed it from the image file temporarily)

wishlist.html

displaywishlist.js

[ATTACH]8921[/ATTACH]

[upl-file uuid=28ef4d50-0a3f-47e9-9080-c4deb99df4b2 size=93kB]my ou files.zip[/upl-file]
Copy linkTweet thisAlerts:
@paulamcclauthorMay 16.2007 — Anybody!
Copy linkTweet thisAlerts:
@Logic_AliMay 16.2007 — Anybody![/QUOTE]It's too laborious to trawl through your files. Host the site as it stands and post the URL.
Copy linkTweet thisAlerts:
@paulamcclauthorMay 16.2007 — It's too laborious to trawl through your files. Host the site as it stands and post the URL.[/QUOTE]

Why on earth would I want or need to host a university assignment??

You just need to place the files on your computer and then open the file called wishlist.html in a browser.
×

Success!

Help @paulamccl spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...