Hi All, i am new to js and have a script which displays hidden divs on after another whilst highlighting a tab at the same time which is working fine ?
however the one let down is that when the page first loads the text area is blank until the timer hits its mark and the first div is shown, my question is how do i get the first div to show at page load???
here is the working code
[CODE]<script type=”text/javascript”>
var timer = window.setInterval(“showNext();”, 4000);
var position = -1;
var array = [“detail_info1”, “detail_info2”, “detail_info3”, “detail_info4”, “detail_info5”, “detail_info6”];
var tabs = [“tab1”, “tab2”, “tab3”, “tab4”, “tab5”, “tab6”];
var currentDisplay = 0;
var currentTab = 0;
function showNext() {
if (position == array.length – 1) {
position = 0;
}
else {
position++;
}
showInfo(position);
}
function showInfo(id) {
currentT = document.getElementById(tabs[currentTab]);
currentD = document.getElementById(array[currentDisplay]);
tab = document.getElementById(tabs[id]);
div = document.getElementById(array[id]);
currentD.style.display = “none”;
currentT.style.background = “white”;
div.style.display = “block”;
tab.style.background = “orange”;
currentDisplay = id;
currentTab = id;
}
function startTimer() {
timer = window.setInterval(“showNext();”, 4000);
}
function stopTimer() {
clearInterval(timer);
}
</script>
and i tried changing this
[CODE]var timer = window.setInterval(“showNext();”, 4000);
var position = -1;
var array = [“detail_info1”, “detail_info2”, “detail_info3”, “detail_info4”, “detail_info5”, “detail_info6”];
var tabs = [“tab1”, “tab2”, “tab3”, “tab4”, “tab5”, “tab6”];
var currentDisplay = 0;
var currentTab = 0;
to this
[CODE]var position = -1;
var array = [“detail_info1”, “detail_info2”, “detail_info3”, “detail_info4”, “detail_info5”, “detail_info6”];
var tabs = [“tab1”, “tab2”, “tab3”, “tab4”, “tab5”, “tab6”];
var currentDisplay = 0;
var currentTab = 0;
showNext();
var timer = window.setInterval(“showNext();”, 4000);
but nothing seems to happen?
any ideas
thanks
Luke