/    Sign up×
Community /Pin to ProfileBookmark

Another question about Breadcrumbs

I did some modifications to this code and the only thing I cant figure out is, which I think should be, a simple if else loop. Here is my code:

This is the for loop, which is ok:

[code=php]
for(var i=0; i<sURL.length; i++) {
if(i==0 && i<sURL.length-1) document.write(‘<a href=”‘+(bURL+=sURL[i])+'”>’+sURL[i]+'</a> &gt; ‘);
[/code]

Here is the problem, I want the first “else if” statement to execute only when it is true. If not then it just executes the second one, with the last “else” statement.

[code=php]
else if(sURL[i].length == document.title.length) document.write(“<b>”+document.title);
else if(i<sURL.length-1) document.write(‘<a href=”‘+(bURL+=”/”+sURL[i])+”/index.jsp”+'”>’+sURL[i]+'</a> &gt; ‘);
else document.write(“<b>”+document.title);
}
[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@js_prof_consMar 28.2005 — Here is the problem, I want the first "else if" statement to execute only when it is true. If not then it just executes the second one, with the last "else" statement.
[code=php]
else if(sURL[i].length == document.title.length) document.write("<b>"+document.title);
else if(i<sURL.length-1) document.write('<a href="'+(bURL+="/"+sURL[i])+"/index.jsp"+'">'+sURL[i]+'</a> &gt; ');
else document.write("<b>"+document.title);
}

[/code]
[/QUOTE]
Umm? Please clarify. I'm not sure I understand.
×

Success!

Help @rmalik1 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.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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