0

Hello,

I have a spry accordion that I have inserted in Dreamweaver with 5 tabs for Monday-Friday.

How could I make the tab active depending on what day it is?

i.e: So if its Tuesday the Tuesday tab will be active.

<div id="TabbedPanels1" class="TabbedPanels">
    <ul class="TabbedPanelsTabGroup">
      <li class="TabbedPanelsTab" tabindex="0">Monday</li>
      <li class="TabbedPanelsTab" tabindex="0">Tuesday</li>
      <li class="TabbedPanelsTab" tabindex="0">Wednesday</li>
      <li class="TabbedPanelsTab" tabindex="0">Thursday</li>
      <li class="TabbedPanelsTab" tabindex="0">Friday</li>
    </ul>

Edited by TheVendor: n/a

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by fxm
0

Would javascript
getDay()
document.getElementById('id').focus()
be any help?

0

So far I have..

My index.html:

<div id="TabbedPanels1" class="TabbedPanels">
    <ul class="TabbedPanelsTabGroup">
      <li class="TabbedPanelsTab" tabindex="0">Monday</li>
      <li class="TabbedPanelsTab" tabindex="1">Tuesday</li>
      <li class="TabbedPanelsTab" tabindex="2">Wednesday</li>
      <li class="TabbedPanelsTab" tabindex="3">Thursday</li>
      <li class="TabbedPanelsTab" tabindex="4">Friday</li>
    </ul>
    <div class="TabbedPanelsContentGroup">
      <div class="TabbedPanelsContent">Content 1</div>
      <div class="TabbedPanelsContent">Content 2</div>
      <div class="TabbedPanelsContent">Content 2</div>
      <div class="TabbedPanelsContent">Content 2</div>
      <div class="TabbedPanelsContent">Content 2</div>
    </div>

and my JS file:

var d=new Date();
var weekday=new Array(5);
weekday[0]= 0;
weekday[1]= 1;
weekday[2]= 3;
weekday[3]= 4;
weekday[4]= 5;


Spry.Widget.TabbedPanels = function(element, opts)
{
	this.element = this.getElement(element);
	this.defaultTab = weekday[d.getDay()]; // Panel selector.
	this.tabSelectedClass = "TabbedPanelsTabSelected";
	this.tabHoverClass = "TabbedPanelsTabHover";
	this.tabFocusedClass = "TabbedPanelsTabFocused";
	this.panelVisibleClass = "TabbedPanelsContentVisible";
	this.focusElement = null;
	this.hasFocus = false;
	this.currentTabIndex = 0;
	this.enableKeyboardNavigation = true;
	this.nextPanelKeyCode = Spry.Widget.TabbedPanels.KEY_RIGHT;
	this.previousPanelKeyCode = Spry.Widget.TabbedPanels.KEY_LEFT;

But I still can't seem to get it to work..

Any help would be great.

Edited by TheVendor: n/a

0

Where would that code go?

Somewhere after the widget is defined

var d = new Date();
var dn = d.getDay();

Use dn to move the focus in the widget (or assign IDs and use document.getElementById(); as I originally suggested).

[Of course there are ways other than ID to access elements.]

0

Somewhere after the widget is defined

var d = new Date();
var dn = d.getDay();

Use dn to move the focus in the widget (or assign IDs and use document.getElementById(); as I originally suggested).

[Of course there are ways other than ID to access elements.]

Okay so I would put that in the index.html and then how would I assign IDs to each?

Would it be here?:

#
<li class="TabbedPanelsTab" tabindex="0">Monday</li>
#
<li class="TabbedPanelsTab" tabindex="1">Tuesday</li>
#
<li class="TabbedPanelsTab" tabindex="2">Wednesday</li>
#
<li class="TabbedPanelsTab" tabindex="3">Thursday</li>
#
<li class="TabbedPanelsTab" tabindex="4">Friday</li>
0

how would I assign IDs

There are plenty of tutorials. Google for getElementById().

Alternatively, "id=" appears at least 170 times in the source of the page you are reading right now.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.