PDA

View Full Version : Random Generation Not Working in FF


greasonwolfe
02-23-2006, 12:16 PM
Not trying to spam the boards, but wanted to seperate these two questions since they are completely unrelated to one another. I am not sure why this isnt working. It was working at one time (at least I seem to remember that it was working) and I don't recall making any changes to it, but for some reason, when I run this script in IE it works just like it is supposed to, but when trying to run it in FF the random generation part always returns an undefined value. If anyone has any ideas why it wouldn't work in FF, I am all ears.



function checkcolor()
{
if (document.stardata.STYPE.options.value!="None")
{
RandomStarColor=document.stardata.STYPE.options[document.stardata.STYPE.selectedIndex].value
}
else
{
var randomcolor=Math.floor(Math.random()*10000)+1
if (randomcolor<=36 || randomcolor>=9965)
{
document.stardata.STYPE.options.value="F"
RandomStarColor="TypeF.gif"
}
if ((randomcolor>=37 && randomcolor<=108) || (randomcolor>=9892 && randomcolor<=9964))
{
document.stardata.STYPE.options.value="A"
RandomStarColor="TypeA.gif"
}
if ((randomcolor>=109 && randomcolor<=325) || (randomcolor>=9674 && randomcolor<=9891))
{
document.stardata.STYPE.options.value="O"
RandomStarColor="TypeO.gif"
}
if ((randomcolor>=326 && randomcolor<=578) || (randomcolor>=9420 && randomcolor<=9673))
{
document.stardata.STYPE.options.value="G"
RandomStarColor="TypeG.gif"
}
if ((randomcolor>=579 && randomcolor<=868) || (randomcolor>=9130 && randomcolor<=9419))
{
document.stardata.STYPE.options.value="B"
RandomStarColor="TypeB.gif"
}
if ((randomcolor>=869 && randomcolor<=1556) || (randomcolor>=8441 && randomcolor<=9129))
{
document.stardata.STYPE.options.value="K"
RandomStarColor="TypeK.gif"
}
if (randomcolor>=1557 && randomcolor<=8440)
{
document.stardata.STYPE.options.value="M"
RandomStarColor="TypeM.gif"
}
}
fillform()
}


And just for the sake of reference, here is the select box the script is working with. . .


<form name="stardata">
<table bordercolorlight="#C0C0C0" bordercolordark="#000000" border="1" cellpadding="0" cellspacing="0" bgcolor="#909090" width="730" align="center">
<tr>
<td colspan="6"><center><font class="labels">Realative Celestial Position Calculator</font></center></td>
</tr>
<tr>
<td colspan="2"><center><font class="identity">Spectral Class : </font>
<select name="STYPE">
<option value="None"></option>
<option value="O">Class O Star</option>
<option value="B">Class B Star</option>
<option value="A">Class A Star</option>
<option value="F">Class F Star</option>
<option value="G">Class G Star</option>
<option value="K">Class K Star</option>
<option value="M">Class M Star</option>
</select>
</center>
</td>

glenngv
02-24-2006, 11:10 AM
It would help if you point out the erroneous line. You can easily see this in the Javascript Console.

greasonwolfe
02-24-2006, 12:20 PM
That's just it, there isn't any error popping up in the console. It just simply doesn't work for some odd reason. If I use the select box, it works out just fine, but if I defer to the random generator, it always comes up as undefined. Almost as if FF isn't recognizing the number that has been generated or something like that.