•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,649 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,874 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 567 | Replies: 1
![]() |
•
•
Join Date: Jan 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
hello, i have what i think is a novice javascript problem, all help is appreciated.
i'm trying to run a couple of the same scripts with different arrays on the same page. the scripts are running fine, the problem is they're both grabbing from one array. normally these scripts live on two different .html includes, but for demo purposes i've combined them on to this one page. advice, thanks.
i'm trying to run a couple of the same scripts with different arrays on the same page. the scripts are running fine, the problem is they're both grabbing from one array. normally these scripts live on two different .html includes, but for demo purposes i've combined them on to this one page. advice, thanks.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body onload="rotater();rotater2()">
<script type="text/javascript">
var howOften = 20; //number often in seconds to rotate
var current = 0; //start the counter at 0
var ns6 = document.getElementById&&!document.all; //detect netscape 6
// images, text, etc in the array elements
var items = new Array();
items[0] = "<div id='testpic'>"
+ "<img src='img/testimonial_3.gif' width='239' height='133' />"
+ "</div>"
+ "<div class='testtext14green'>"
+ "“Atempo Live Backup was the only backup product capable of easily meeting all of our data protection objectives with out of the box Xsan support.”"
+ "</div>"
+ "<div class='testtext12green'>"
+ "Mark Miranda, IT Director The Cimarron Group"
+ "<br /><br />"
+ "</div>";
items[1] = "<div id='testpic'>"
+ "<img src='img/testimonial_3_red.gif' width='239' height='133' />"
+ "</div>"
+ "<div class='testtext14red'>"
+ "“Atempo Live Backup was the only backup product capable of easily meeting all of our data protection objectives with out of the box Xsan support.”"
+ "</div>"
+ "<div class='testtext12red'>"
+ "Mark Miranda, IT Director The Cimarron Group"
+ "<br /><br />"
+ "</div>";
function rotater() {
if(document.layers) {
document.placeholderlayer.document.write(items[current]);
document.placeholderlayer.document.close();
}
if(ns6)document.getElementById("placeholderdiv").innerHTML=items[current]
if(document.all)
placeholderdiv.innerHTML=items[current];
current = (current==items.length-1) ? 0 : current+1; //increment or reset
setTimeout("rotater()",howOften*1000);
}
function randOrd() {
return (Math.round(Math.random())-0.5);
}
items.sort( randOrd );
</script>
<div id="placeholderdiv"></div>
<script type="text/javascript">
var howOften = 20; //number often in seconds to rotate
var current = 0; //start the counter at 0
var ns6 = document.getElementById&&!document.all; //detect netscape 6
// images, text, etc in the array elements
var items = new Array();
items[0] = "<div id='solImage2'>"
+ "<img src='img/solutions_govt.gif' alt='Solutions for Government'/>"
+ "</div>"
+ "<div class='solTextHdRed'>"
+ "Solutions for Government"
+ "</div>"
+ "<div class='soltext12Red'>"
+ "Insert text here that has information for Solutions for Government<br />"
+ "<br />"
+ "<a class='white12' href='.html'>Find out more</a> "
+ "<a href='.html'><img class='findmore' src='img/arrow.gif' border='0'/></a>"
+ "<br /><br />"
+ "</div>";
items[1] = "<div id='solImage2'>"
+ "<img src='img/solutions_financial.gif' alt='Solutions for Financial Services'/>"
+ "</div>"
+ "<div class='solTextHdGrn'>"
+ "Solutions for Financial Services"
+ "</div>"
+ "<div class='soltext12Grn'>"
+ "Insert text here that has information for Solutions for Financial Services<br />"
+ "<br />"
+ "<a class='white12' href='.html'>Find out more</a> "
+ "<a href='.html'><img class='findmore' src='img/arrow.gif' border='0'/></a>"
+ "<br /><br />"
+ "</div>";
function rotater2() {
if(document.layers) {
document.placeholderlayer.document.write(items[current]);
document.placeholderlayer.document.close();
}
if(ns6)document.getElementById("placeholderdiv2").innerHTML=items[current]
if(document.all)
placeholderdiv2.innerHTML=items[current];
current = (current==items.length-1) ? 0 : current+1; //increment or reset
setTimeout("rotater2()",howOften*1000);
}
function randOrd2() {
return (Math.round(Math.random())-0.5);
}
items.sort( randOrd2 );
</script>
<span id="placeholderdiv2"></span>
</body>
</html> try working with concrete divs instead of in-memory ones. play around with their visibility or display attributes if you wish, other wise your mark-up seems so confusing. and i suggest creating your array with the div ids or the div objects like :
items[0] = document.getElementById('foo');
then you can work with them more easily
Serkan Şendur
items[0] = document.getElementById('foo');
then you can work with them more easily
Serkan Şendur
Serkan Şendur
MCAD.NET
MCAD.NET
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
ajax asp cross-browser javascript menu with few lines of code developer development firefox home html internet javascript javascript smooth scrolling scroll smoothly window document position javascript tab menu with rounded corners generator microsoft msdn office prevent javascript menu from getting hidden under flash movies site software sql vista web
- E-business tool needed (eCommerce)
- do u advice me to do my online store using ASP or PHP (IT Technologies and Trends)
- Help-IE6 blocking my java applets (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Problem with ajax and mozilla browser
- Next Thread: Assign count output to a variable!


Linear Mode