display items in turn
Posted: Thu Mar 15, 2012 10:31 am
I'm trying to find a way to take items in an array, and display them, one after the other. My idea is to create two hidden tables, and then use javascript to display them in turn for 5 seconds.
so far I have:
The two tables display fine (if changed to display:block), but that's about as far as I have got. Any pointers would be very welcome.
so far I have:
Code: Select all
<!-- THIS SECTION CREATES TWO HIDDEN TABLES WITH THE ID's 'Test', 'Test 1'-->
<?php
$a = 0;
foreach($sqDBArray AS $sq){
print "<div id=\"$sq\" style=\"position:absolute; left:50%; top:50%; display:none;\">\n";
print " <table style=\"width:400px; position:relative; left:-200px; top:-110px; background-color:$sqCol; padding:10px; z-index:2\">\n";
print " <tr>\n";
print " <th class=\"Round\" style=\"vertical-align:middle; height:300px;\">";
print $sq;
print " </th>\n";
print " </tr>\n";
print " </table>\n";
print "</div>\n";
$a++;
};
?>
<script type="text/javascript">
<!-- CREATE JAVASCRIPT ARRAY -->
var dbArray = ['<?php print str_replace(",","','",$sqDB); ?>'];
//This creates an Array like dbArray=['test','test 1'];
<!-- SHOW / HIDE WINDOW FUNCTIONS -->
function hide(id)
{
document.getElementById(id).style.display='none';
}
function show(id)
{
document.getElementById(id).style.display='block';
setTimeout('hide();', 5000); // 5 seconds
}
for (i=0; i<dbArray; i++)
{
show(dbArray[i]);
//document.write(dbArray[i]);
}
</script>