PDA

View Full Version : A little debugging needed


Antoniohawk
10-20-2002, 09:36 PM
Can some1 tell me what is wrong with this? If u have any questions please ask. Here is a link to the actual calculator so that you can kind of see what it is used for. Calculator (http://www.avidgamers.com/RuneRaiders/prayercalc.html)

<html>
<head>
<style>
INPUT {
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 10px;
border: 1px green solid;
background-color: #000000;
color: #ffffff;
}
</style>
<script language=javascript>
function calcFire(in1,in2,out,out2,lvl1,lvl4,lvl7,lvl10,lvl13,lvl16,lvl19,lvl22,lvl25,lvl28,lvl31,lvl34,lvl37 ,lvl40){
var num1 = parseInt(in1.value,10);
var num2 = parseInt(in2.value,10);
if (isNaN(num1) || num1<0){
alert("Please enter a positive number for field 1.");
in1.focus();
return;
}
if (isNaN(num2) || num2<0){
alert("Please enter a positive number for field 2.");
in2.focus();
return;
}

out.value = (num1-num2)/3.75;
out2.value = (num1-num2)/12.5;

if (num2 >= 276)
{
lvl4.style.backgroundColor="green"
}
else
{
lvl4.style.backgroundColor="red"
}


if (num2 >= 650)
{
lvl7.style.backgroundColor="green"
}
else
{
lvl7.style.backgroundColor="red"
}


if (num2 >= 1154)
{
lvl10.style.backgroundColor="green"
}
else
{
lvl10.style.backgroundColor="red"
}


if (num2 >= 1833)
{
lvl13.style.backgroundColor="green"
}
else
{
lvl13.style.backgroundColor="red"
}


if (num2 >= 2746)
{
lvl16.style.backgroundColor="green"
}
else
{
lvl16.style.backgroundColor="red"
}


if (num2 >= 276)
{
lvl19.style.backgroundColor="green"
}
else
{
lvl19.style.backgroundColor="red"
}


if (num2 >= 5624)
{
lvl22.style.backgroundColor="green"
}
else
{
lvl22.style.backgroundColor="red"
}


if (num2 >= 7842)
{
lvl25.style.backgroundColor="green"
}
else
{
lvl25.style.backgroundColor="red"
}


if (num2 >= 10824)
{
lvl28.style.backgroundColor="green"
}
else
{
lvl28.style.backgroundColor="red"
}


if (num2 >= 14833)
{
lvl31.style.backgroundColor="green"
}
else
{
lvl31.style.backgroundColor="red"
}


if (num2 >= 20224)
{
lvl34.style.backgroundColor="green"
}
else
{
lvl34.style.backgroundColor="red"
}


if (num2 >= 27473)
{
lvl37.style.backgroundColor="green"
}

else
{
lvl37.style.backgroundColor="red"
}


if (num2 >= 37224)
{
lvl40.style.backgroundColor="green"
}
else
{
lvl40.style.backgroundColor="red"
}


}
</script>
</head>
<body>
<table cellspacing="2" cellpadding="0">
<th colspan="2"><center><b>Prayer</b></center></th>
<tr>
<td bgcolor="gray" style="font-size:15px; color: white; padding-left: 10px; padding-right: 10px; padding-top: 10px; border:1px #000000 solid" colspan="2">
<form name="fireform">
Enter in your Prayer experience: <input name="fire2">
<br>
Enter in the experience you would like: <input name="fire1">
<br>
<center><input type="button" value="Submit" onclick="calcFire(this.form.fire1,this.form.fire2,this.form.fireoutput,this.form.fireoutput2)","colorchange(lvl1,lvl4,lvl7,lvl10,lvl13,lvl16,lvl19,lvl22,lvl25,lvl28,lvl31,lvl34,lvl37,lvl40)"></center>
<br>
</td>
</tr>
<tr>
<td bgcolor="gray" style="font-size:15px; color: white; padding-left: 10px; padding-right: 10px; padding-top: 10px; border:1px #000000 solid" colspan="2">
You have to bury <input name="fireoutput"> small bones!
<br>
You have to bury <input name="fireoutput2"> big bones!
</form>
</td>
</tr>
</table>
<table style="border:1px green solid; padding-left: 10px; padding-right: 10px;" width="500">
<tr>
<td><b>Level<b></td>
<td><b>Prayer<b></td>
</tr>
<tr>
<td>1</td>
<td bgcolor="green">Thick Skin</td>
</tr>
<tr>
<td>4</td>
<td name="lvl4">Burst of Strength</td>
</tr>
<tr>
<td>7</td>
<td name="lvl7">Clarity of Thought</td>
</tr>
<tr>
<td>10</td>
<td name="lvl10">Rock Skin</td>
</tr>
<tr>
<td>13</td>
<td name="lvl13">Superhuman Strength</td>
</tr>
<tr>
<td>16</td>
<td name="lvl16">Improved Reflexes</td>
</tr>
<tr>
<td>19</td>
<td name="lvl19">Rapid Restore</td>
</tr>
<tr>
<td>22</td>
<td name="lvl22">Rapid Heal</td>
</tr>
<tr>
<td>25</td>
<td name="lvl25">Protect Items</td>
</tr>
<tr>
<td>28</td>
<td name="lvl28">Steel Skin</td>
</tr>
<tr>
<td>31</td>
<td name="lvl31">Ultimate Strength</td>
</tr>
<tr>
<td>34</td>
<td name="lvl34">Incredible Reflexes</td>
</tr>
<tr>
<td>37</td>
<td name="lvl37">Paralyze Monster</td>
</tr>
<tr>
<td>40</td>
<td name="lvl40">Protect From Missiles</td>
</tr>
</table>
<br>
<br>
<center>Created by Antoniohawk</center>
<br><center>Feel free to use the calculators as long as credit is given to the creator</center>
<br>
</body>
</html>

mordred
10-21-2002, 01:13 AM
I've got one question to you: Where's your problem? Might seem obvious to you, but remember that I (and presumably a lot of other members) am not the creator of that script, so how should I know?

If you want some "debugging", you better point out which "bug" shall be exterminated. Always be as detailed as possible, we can't mindread.

Antoniohawk
10-22-2002, 01:41 AM
Ok lets see if I can explain this simply...
if u look at the webpage u will see a calculator and a series of bars with thing such as Thick Skin, Rock Skin, And Incredible Reflexes in them. We will use Incredible reflexes as our example. What i want to do is, if the number entered into the first field of the form is less greater than or equal to 20224 then the bar, or table cell that the words "Incredible Reflexes" is in will have a background color of green. The same goes for all of the other skills listed. To explain the calculator, i will add some comments to the above code. THX for informing me to describe the purpose of the script, i was a lil rushed. Also THX for any help that will be provided.