PDA

View Full Version : Using arrays with forms


Antoniohawk
10-20-2002, 07:45 PM
here is a simple calculator that was made for a game called Runescape (http://www.runescape.com)

<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 calcWood(in1,in2,in3,out){
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)/in3.options[in3.selectedIndex].value;
}

</script>
</head>
<body>

<table cellspacing="2" cellpadding="0">
<th colspan="2"><center><b>Woodcutting</b></center>
<tr>
<td bgcolor="gray" style="font-size:15px; color: white; padding-left: 10px; padding-right: 10px; padding-top: 10px; border:1px #000000 solid">
<form name="woodform">
Enter in the experience you would like: <input name="wood1">
<br>
Enter in your fishing experience: <input name="wood2">
<br>
<center><input type="button" value="Submit" onclick="calcWood(this.form.wood1,this.form.wood2,this.form.woodtype,this.form.woodoutput)"></center>
<br>
</td>
<td bgcolor="gray" style="font-size:15px; color: white; padding-left: 10px; padding-right: 10px; padding-top: 10px; border:1px #000000 solid" rowspan="2">
Select what you will fish:
<select name="woodtype">
<option value="10">Shrimp</option>
<option value="20">Sardine</option>
<option value="30">Herring</option>
<option value="10">Mackeral**</option>
<option value="40">Anchovy</option>
<option value="50">Trout</option>
<option value="15">Cod**</option>
<option value="60">Pike</option>
<option value="70">Salmon</option>
<option value="80">Tuna</option>
<option value="90">Lobster</option>
<option value="25">Bass**</option>
<option value="100">Swordfish</option>
<option value="30">Lava Eel*</option>
<option value="110">Shark*</option>
</select>
<br>
* members fish
<br>
** fish caught with big net maximum of 5 at a time
</tr>
<tr>
<td bgcolor="gray" style="font-size:15px; color: white; padding-left: 10px; padding-right: 10px; padding-top: 10px; border:1px #000000 solid">
You have to catch <input name="woodoutput"> whatever u chose!

</form>
</td>
</tr>
</table>
</body>
</html>


After the form where you enter in the experience that you want, i want a form that u can just enter in the level that you would like to get to (ie. 1,2,3,4,5). Each number equals a certain number of experience points, for example 2 equals 83. If you have any questions please ask them. Look at the calculator first at My Calculator (http://www.avidgamers.com/RuneRaiders/fishcalc.html). THX for you r help in advance!

Antoniohawk
10-22-2002, 04:10 AM
Help Is Still Needed. I know some1 out there can help me.

RadarBob
10-22-2002, 01:47 PM
Deja Vu all over again!:rolleyes:

Help is still needed.
Specifics would be nice.:D

Antoniohawk
10-23-2002, 12:51 PM
The first field is for the experience that you would like. The second field is for the experience that you have. All of the options in the drop down, have a certain value, such as shrimp, which is 10. When the submit button is pressed, the equation, "(field1 - field2) / value of item in drop down". The Result of this equation is then printed out into the remaining field. What I want to do is this. I would like to have another field, in between the first and second field that you type a single number in. This number represents another number that will be defined in an array. I hope that helps.

Antoniohawk
10-30-2002, 09:17 PM
I specified what i needed, so please some1 help me.