Wednesday, 2 October 2013

"Member not found" error in IE6: from .style edit or getElementById or...?

"Member not found" error in IE6: from .style edit or getElementById or...?

I volunteered to develop this script for a small organisation (as part of
my self-training in programming). It randomly selects a seat in a room
(spending a few seconds keeping viewers guessing which seat was selected).
Since I use a Mac, I tested mainly with Firefox, where it works like a
charm. Turns out that the computer in their room runs Internet Explorer 6
on Windows XP (and they had to enable active content in local files).
They called me to inform me of an error and based on the information they
gave, the guilty line is either RowNumberDisplay.style = "color: #FF0000";
or var RowNumberDisplay = document.getElementById("RowNumber");. Quick
searches on Google and Stack Overflow for getElementById and .style
problems in IE6 were fruitless (a common problem is false matches due to
name attributes, but the div in question has no name attribute). Thanks in
advance for any answers helping identify and address this error.
<!doctype html>
<html>
<head>
<title>The Lucky Person</title>
<style type="text/css">
input#SelectLuckyPerson
{
height: 150px;
font-size: 60px;
}
p#RowDetails, p#SeatDetails, div#RowNumber, div#SeatNumber
{
font-size: 100px;
display: inline;
}
div#RowNumber, div#SeatNumber
{
color: #0000FF;
}
</style>
</head>
<body>
<div id="LuckyPersonIs"><input type="button"
id="SelectLuckyPerson" value="And the lucky person is..."
onClick="GetResults();"></div>
<p id="RowDetails">Row number: <div id="RowNumber">0</div></p>
<p id="SeatDetails">Seat number: <div id="SeatNumber">0</div></p>
<script>
var MinRow = 2;
var MaxRow = 8;
var SeatsInRow = new Array();
SeatsInRow[1] = 25;
SeatsInRow[2] = 25;
SeatsInRow[3] = 27;
SeatsInRow[4] = 27;
SeatsInRow[5] = 27;
SeatsInRow[6] = 27;
SeatsInRow[7] = 29;
SeatsInRow[8] = 31;
SeatsInRow[9] = 31;
SeatsInRow[10] = 31;
SeatsInRow[11] = 31;
SeatsInRow[12] = 33;
SeatsInRow[13] = 33;
SeatsInRow[14] = 33;
var ShuffleSpeed = 200;
var RowNumberDisplay = document.getElementById("RowNumber");
var SeatNumberDisplay = document.getElementById("SeatNumber");
var ChosenRow, ChosenSeat
function GetResults()
{
var IsRunning = CheckStatus();
if (IsRunning)
{
ChosenRow = ChooseRow();
ChosenSeat = ChooseSeat();
RowNumberDisplay.style = "color: #FF0000";
SeatNumberDisplay.style = "color: #FF0000";
ShowRowResult = window.setInterval("TryRowResult()",
ShuffleSpeed);
if (DelaySeats == false)
{
ShowSeatResult =
window.setInterval("TrySeatResult()",
ShuffleSpeed);
}
}
}
function ChooseRow()
{
return Math.floor(Math.random() * (MaxRow - MinRow)) +
MinRow;
}
function ChooseSeat()
{
return Math.ceil(Math.random() * SeatsInRow[ChosenRow]);
}
function TryRowResult()
{
TryRow = ChooseRow();
RowNumberDisplay.innerHTML = TryRow;
if (TryRow == ChosenRow)
{
window.clearInterval(ShowRowResult);
document.getElementById("RowNumber").style = "color:
#0000FF";
if (DelaySeats == true)
{
ShowSeatResult =
window.setInterval("TrySeatResult()",
ShuffleSpeed);
}
}
}
function TrySeatResult()
{
TrySeat = ChooseSeat();
SeatNumberDisplay.innerHTML = TrySeat;
if (TrySeat == ChosenSeat)
{
window.clearInterval(ShowSeatResult);
document.getElementById("SeatNumber").style = "color:
#0000FF";
}
}
function CheckStatus()
{
if (RowNumberDisplay.style.color == "rgb(255, 0, 0)" ||
SeatNumberDisplay.style.color == "rgb(255, 0, 0)")
{
return false;
}
return true;
}
</script>
</body>
</html>

No comments:

Post a Comment