/    Sign up×
Community /Pin to ProfileBookmark

Another Problem with Simple Javascript

I am writing code that can sort posts on a blog site. If the page isn’t being sorted by a label a link to the label is provided. If the page is being sorted by a label the label is listed in bold with no link. I am using the following javascript to do this:

[CODE]if (window.location.href == 'http://flashcreations-faq.blogspot.com/search/label/Windows Vista') {
document.getElementById('sort1a').style.display = 'none';
document.getElementById('sort1b').style.display = 'block';
}

if (window.location.href == 'http://flashcreations-faq.blogspot.com/search/label/Windows XP') {
document.getElementById('sort2a').style.display = 'none';
document.getElementById('sort2b').style.display = 'block';
}

if (window.location.href == 'http://flashcreations-faq.blogspot.com/search/label/both_OS') {
document.getElementById('sort3a').style.display = 'none';
document.getElementById('sort3b').style.display = 'block'
}[/CODE]

With the following HTML:

[CODE]<ul><li id=”sort1a”><a href=”http://flashcreations-faq.blogspot.com/search/label/Windows Vista”>Windows Vista (2)</a></li>
<li id=”sort1b” style=”display:none”><strong>Windows Vista (2)</strong></li>
<li id=”sort2a”><a href=”http://flashcreations-faq.blogspot.com/search/label/Windows XP”>Windows XP (0)</a></li>
<li id=”sort2b” style=”display:none”><strong>Windows XP (0)</strong></li>
<li id=”sort3a”><a href=”http://flashcreations-faq.blogspot.com/search/label/both_OS”>Both (9)</a></li>
<li id=”sort3b” style=”display:none”><strong>Both (9)</strong></li></ul>[/CODE]

To achieve this. You can see a live example of this on my blog: [url]http://flashcreations-faq.blogspot.com/[/url]

The problem is only the Both label will bold when sorting by it. The other two stay the same. Please Help Me!!!
Thank You So Much!!!!
webcoder13

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@webcoder13authorJul 09.2008 — Please Help Me!!!!!!! Thanks!
Copy linkTweet thisAlerts:
@toicontienJul 09.2008 — I just whipped this together. It works for me, and it completely depends on the web address. Take a look, and if you have any questions, post your code here.

[upl-file uuid=6950c971-2cd4-49ea-a0db-b32569b60c9a size=1kB]LabelSorter.zip[/upl-file]
×

Success!

Help @webcoder13 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.16,
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,
)...