cjhoney — 2012-04-09T06:20:14-04:00 — #1
I'm trying to create a navigation bar with four elements. If the element is currently selected it will have a "red" background image, if it is one of the other 3, it will have a "black" background image. my four tabs are 'timetable, homework, notifications and sport' I tried making 8 functions like the 2 below
document.getElementById("time").style.ClassName = 'timetable_r';
document.getElementById("time").style.ClassName = 'time_r';
And then four blocks like this:
var timePath = new String();
timePath = document.getElementById("timetable").style.backgroundImage;
if(timePath == "url(assets/img/tabs/time_black.png)" || timePath == "")
finally, my html has this:
<a href"#" onclick="changeTimeButton()">
<li id="timetable" class="time_b">
<a href"#" onclick="changeHomeButton()">
<li id="homework" class="home_b">
<a href"#" onclick="changeNotiButton()">
<li id="notifications" class="noti_b">
<a href"#" onclick="changeSportButton()">
<li id="sport" class="sport_b">
It works once then does nothing. Why, and how would I go about fixing this?? Please help!
ralphm — 2012-04-09T07:53:58-04:00 — #2
Hi cjhoney. Welcome to the forums.
That all looks a bit convoluted. It's easier to style links like that using CSS or PHP. Have a look at this recent thread which discusses both approaches:
cjhoney — 2012-04-09T10:18:44-04:00 — #3
ralphm — 2012-04-09T11:14:06-04:00 — #4
Yes, it's easy with jQuery:
But don't forget the CSS option, too. It works with JS off, and doesn't require a big library. (I guess if you are already downloading the library for other purposes, that's irrelevant, of course.)
cjhoney — 2012-04-09T11:51:48-04:00 — #5
The links don't really help, I think I'm taking the wrong approach.... My aim is to have one file that ALL the content is viewed in, with two navigation bars, one at the top, one at the bottom, and a sort of "window" in the middle. The bottom navigation has four links, and the one at the top has three, but the three top links are different depending on what page you are viewing. so when I click the timetable link on the bottom navigation, I get the timetable for the day, with the day link at the top of the page selected. When I click "week" on the top, the 'Timetable' stays selected but the the 'day' becomes deselected, and the content in the window changes to the week. I don't need any special effects, or flashes or shiny buttons. I just need this simple page, but I CANNOT load a new page entirely, all the content has to be available through the index.html file. AND it all has to function from a flash drive on any computer, so no online links or content. It's really confusing me... How would I go about doing this?
ralphm — 2012-04-09T20:28:51-04:00 — #6
Are you talking about a page kind of like this:
As you click the menu links, the page scrolls up or down, and the current section link is highlighted.
paul_wilkins — 2012-04-09T21:15:58-04:00 — #7
Or, is the functionality that's being look for like a tabbed interface?
cjhoney — 2012-04-10T06:12:58-04:00 — #8
Yay!! Thanks Paul, that's exactly what I'm looking for, I just need to implement two. Can you put a tab within one of the tabs?
paul_wilkins — 2012-04-10T06:54:36-04:00 — #9
Yes you can. Nested tabs demo