MedtronicVascSR
asked on
Need to toggle STYLE.DISPLAY value of elements in an ARRAY of DIV tags.
I have a set of <DIV>'s with identical ID's such as the following:
<DIV ID="content" STYLE="display:inline;">Di splay Text</DIV>
<DIV ID="content" STYLE="display:none;">Disp lay Text</DIV>
<DIV ID="content" STYLE="display:none;">Disp lay Text</DIV>
<DIV ID="content" STYLE="display:none;">Disp lay Text</DIV>
Notice that only the first one is actually visible.
I need to write a function that loops through the array DOCUMENT.ALL("content") and sets STYLE.DISPLAY = "none" for all elements, records which one was "inline" last, and set the next element in the array to "inline". If it gets to the last element, then the first one needs to be set to "inline", and the sequence repeats.
The function will be called with a timer. So each time it runs, it will examine the state of the DOCUMENT.ALL("content") elements, and roll the "inline" property to the next one in sequence.
Here's a visualization of how the function should operate if run for 7 iterations in sequence on 4 DIV objects. X stands for "style.display = inline", O stands for "style.display = none".
1: X O O O
2: O X O O
3: O O X O
4: O O O X
5: X O O O
6: O X O O
7: .......
Any takers?
<DIV ID="content" STYLE="display:inline;">Di
<DIV ID="content" STYLE="display:none;">Disp
<DIV ID="content" STYLE="display:none;">Disp
<DIV ID="content" STYLE="display:none;">Disp
Notice that only the first one is actually visible.
I need to write a function that loops through the array DOCUMENT.ALL("content") and sets STYLE.DISPLAY = "none" for all elements, records which one was "inline" last, and set the next element in the array to "inline". If it gets to the last element, then the first one needs to be set to "inline", and the sequence repeats.
The function will be called with a timer. So each time it runs, it will examine the state of the DOCUMENT.ALL("content") elements, and roll the "inline" property to the next one in sequence.
Here's a visualization of how the function should operate if run for 7 iterations in sequence on 4 DIV objects. X stands for "style.display = inline", O stands for "style.display = none".
1: X O O O
2: O X O O
3: O O X O
4: O O O X
5: X O O O
6: O X O O
7: .......
Any takers?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ZVonko, you're a MACHINE! That works beautifully.
Best regards,
Carlos
Best regards,
Carlos
:-)
what are you trying to accomplish with this? i think you
are just wanting the text to change with a timer is this
correct? if it is it would be better to make and array of
the different text's you want displayed and then change
the node value for the div's text node with the setTimeout
function.