I developed a simple app that would choose a random quote and display it in a div. Using arrays and these bits of code:
function WriteText(arraynum)
{
switch(arraynum)
{
case 1:
var ArrLen=SprQuotes.length;
var ArrNum=(Math.floor(Math.random()*ArrLen));
var txt=SprQuotes[ArrNum];
break;
case 2:
var ArrLen=HisQuotes.length;
var ArrNum=(Math.floor(Math.random()*ArrLen));
var txt=HisQuotes[ArrNum];
break;
case 3:
var ArrLen=LitQuotes.length;
var ArrNum=(Math.floor(Math.random()*ArrLen));
var txt=LitQuotes[ArrNum];
break;
case 4:
var ArrLen=RelQuotes.length;
var ArrNum=(Math.floor(Math.random()*ArrLen));
var txt=RelQuotes[ArrNum];
break;
case 5:
var ArrLen=PresQuotes.length;
var ArrNum=(Math.floor(Math.random()*ArrLen));
var txt=PresQuotes[ArrNum];
break;
case 6:
var ArrLen=MiscQuotes.length;
var ArrNum=(Math.floor(Math.random()*ArrLen));
var txt=MiscQuotes[ArrNum];
break;
default:
var txt="";
var ArrLen=0;
}
document.getElementById('text1').innerHTML=txt;
}
And in the body
<img src="images/book.jpg" width="276" height="300" usemap="#bookmap" class="usi"/></center>
<map name="bookmap">
<area shape="rect" coords="0,0,276,50" onclick="WriteText(5)"/>
<area shape="rect" coords="0,50,276,100" onclick="WriteText(2)"/>
<area shape="rect" coords="0,100,276,150" onclick="WriteText(3)"/>
<area shape="rect" coords="0,150,276,200" onclick="WriteText(4)"/>
<area shape="rect" coords="0,200,276,250" onclick="WriteText(1)"/>
<area shape="rect" coords="0,250,276,300" onclick="WriteText(6)"/>
</map>
<p>
<div style="width:300px;height:600px;top:360px;margin:auto;" id="text1"></div>
<p>
I was able to get the strings saved in the arrays to display when the areas of the image were clicked. However, after filling in thousands of quotes into the arrays, this no longer works. No text is displayed in the div. Can anyone see why this would stop working? I didn't modify anything in the WriteText function after it was working, and the imagemap is recognized when I test it on my phone. I kept the syntax of the arrays the exact same when switching from dummy text to quote text.