/    Sign up×
Community /Pin to ProfileBookmark

Cannot find syntax error

Hey guys!

I need a second pair of eyes here.

This loop was running fine, then I stopped it and started it again and now I am getting a syntax error on the line where it sets the marker.

[code=php]
<script type=”text/javascript”>
var topics = new Array(“Arts”, “Business”, “Computer”, “Education”, “Entertainment”, “Health”, “News”, “Recreation”, “Science”, “Society”);
var links = new Array();
var found = false;

for(i=0; i < topics.length; i++){
var this_topic = topics[0];
for(j=0; j < document.links.length; j++){
var node = document.links[j];
if(node.firstChild.nodeValue == null)continue;
var marker = node.getAttribute(‘href’).lastIndexOf(‘/’, 0);
if(node.getAttribute(‘href’).substr(marker+1, this_topic.length)) == this_topic){
if(!found){
found = true;
node.setAttribute(‘class’, ‘parent’);
}else{
node.setAttribute(‘class’, ‘child’);
}
}

}
topics.shift();
found = false;
}

</script>
[/code]

Thx!

[b]RESOLVED[/b]

if(node.getAttribute(‘href’).substr(marker+1, this_topic.length)[COLOR=Red])[/COLOR]

1 too many

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gphApr 26.2006 — <i>
</i>if(node.getAttribute('href').substr(marker+1, this_topic.length)[COLOR=Red])[/COLOR] == this_topic)


Also, this_topic and node should be declared as variables outside of the loops.
Copy linkTweet thisAlerts:
@CrazyMerlinauthorApr 26.2006 — yeah, I was just being sloppy.....I wrote the code as I went along and haven't formatted it yet


thx
×

Success!

Help @CrazyMerlin 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...