DClayton
01-02-2008, 04:38 PM
DHTML Tabs
(http://www.dynamicdrive.com/dynamicindex17/tabcontent.htm)
I am a complete beginner when it comes to Javascript and would like to implement a modification to the DHTML Tabs script. Baiscally, i would like to use 3 images for each tab. I have managed to get something working which looks as follows:
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/Example.jpg
Ignore the gaps in the images, i can fix that quite easily. The code to produce this is as follows:
<ul id="AttributeTabs" class="shadetabs">
<li id="DescriptionStart" class="SelectedStart"></li>
<li><a href="#" rel="Description" class="selected">Description</a></li>
<li id="DescriptionEnd" class="SelectedEnd"></li>
<li id="New FeaturesStart" class="NonSelectedStart"></li>
<li><a href="#" rel="New Features">New Features</a></li>
<li id="New FeaturesStart" class="NonSelectedEnd"></li>
<li id="FeaturesStart" class="NonSelectedStart"></li>
<li><a href="#" rel="Features">Features</a></li>
<li id="FeaturesEnd" class="NonSelectedEnd"></li>
<li id="VariantStart" class="NonSelectedStart"></li>
<li><a href="#" rel="Variant">Variant</a></li>
<li id="VariantEnd" class="NonSelectedEnd"></li>
</ul>
What i have done is use three list item tags for each tab. Each tab has a start image, a middle section and an end image. The problem i have is that when a different tab is selected, the start and end images do not change. For example:
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/Example2.jpg
I can put into words what i want to do in the javascript but i have no idea where to implement it or the syntax to use.
1. Loop through the <ul> element and retrieve the names of the rel attributes of the <a> tags into an array.
2. For each rel attribute found, look for the <li> element with the id tag[ReturnedRelAttribute] + "Start" and change its class attribute from "SelectedStart" to "NonSelectedStart" or vice versa.
3. Same as step 2 but looking for the <li> element with the id tag [ReturnedRelAttribute] + "End" and change its class attribute from "SelectedEnd" to "NonSelectedEnd" or vice versa.
I think that would then achieve the effect that i am hoping for. The files used for this so far are as follows:
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/default.htm
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/tabcontent.css
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/tabcontent.js
All of the image files used are also in that directory so if you need them you can get to them using:
"http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/" + filename.
I hope this is enough information and i would be greatful if someone could post the Javascript i need to do this.
Thanks in advance
DClayton
(http://www.dynamicdrive.com/dynamicindex17/tabcontent.htm)
I am a complete beginner when it comes to Javascript and would like to implement a modification to the DHTML Tabs script. Baiscally, i would like to use 3 images for each tab. I have managed to get something working which looks as follows:
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/Example.jpg
Ignore the gaps in the images, i can fix that quite easily. The code to produce this is as follows:
<ul id="AttributeTabs" class="shadetabs">
<li id="DescriptionStart" class="SelectedStart"></li>
<li><a href="#" rel="Description" class="selected">Description</a></li>
<li id="DescriptionEnd" class="SelectedEnd"></li>
<li id="New FeaturesStart" class="NonSelectedStart"></li>
<li><a href="#" rel="New Features">New Features</a></li>
<li id="New FeaturesStart" class="NonSelectedEnd"></li>
<li id="FeaturesStart" class="NonSelectedStart"></li>
<li><a href="#" rel="Features">Features</a></li>
<li id="FeaturesEnd" class="NonSelectedEnd"></li>
<li id="VariantStart" class="NonSelectedStart"></li>
<li><a href="#" rel="Variant">Variant</a></li>
<li id="VariantEnd" class="NonSelectedEnd"></li>
</ul>
What i have done is use three list item tags for each tab. Each tab has a start image, a middle section and an end image. The problem i have is that when a different tab is selected, the start and end images do not change. For example:
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/Example2.jpg
I can put into words what i want to do in the javascript but i have no idea where to implement it or the syntax to use.
1. Loop through the <ul> element and retrieve the names of the rel attributes of the <a> tags into an array.
2. For each rel attribute found, look for the <li> element with the id tag[ReturnedRelAttribute] + "Start" and change its class attribute from "SelectedStart" to "NonSelectedStart" or vice versa.
3. Same as step 2 but looking for the <li> element with the id tag [ReturnedRelAttribute] + "End" and change its class attribute from "SelectedEnd" to "NonSelectedEnd" or vice versa.
I think that would then achieve the effect that i am hoping for. The files used for this so far are as follows:
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/default.htm
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/tabcontent.css
http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/tabcontent.js
All of the image files used are also in that directory so if you need them you can get to them using:
"http://www.dcwebspace.pwp.blueyonder.co.uk/JSProblem/" + filename.
I hope this is enough information and i would be greatful if someone could post the Javascript i need to do this.
Thanks in advance
DClayton