Antoniohawk
09-24-2002, 01:55 AM
Can someone plz debug this code?
<html>
<head>
<style>
INPUT {
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 10px;
border: 1px green solid;
background-color: #000000;
color: green;
}
</style>
</head>
<body>
<script language=javascript>
function calc(f){
var num1 = f.fire1.value;
var num2 = f.fire2.value;
var num3 = f.fire3.value;
if (isNaN(num1)){
alert("Number 1 must be numeric.");
f.fire1.focus();
return;
}
else if (isNaN(num2)){
alert("Number 2 must be numeric.");
f.fire2.focus();
return;
}
else if (isNaN(num3)){
alert("Number 3 must be numeric.");
f.fire3.focus();
return;
}
else if (num3=="0"){
alert("Number 3 must not be zero.");
f.fire3.focus();
return;
}
f.fireoutput.value = (num1-num2)/num3;
}
</script>
<script language=javascript>
function calcwood(f){
var num1 = f.wood1.value;
var num2 = f.wood2.value;
var num3 = f.wood3.value;
if (isNaN(num1)){
alert("Number 1 must be numeric.");
f.fire1.focus();
return;
}
else if (isNaN(num2)){
alert("Number 2 must be numeric.");
f.fire2.focus();
return;
}
f.woodoutput.value = (num1-num2)/num3;
}
</script>
<table cellspacing="2" cellpadding="0">
<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="form">
Enter in the experience you would like: <input name="fire1">
<br>
Enter in your firemaking experience: <input name="fire2">
<br>
Enter in how much exp. you get per fire: <input name="fire3">
<center><input type="button" value="Submit" onclick="calc(this.form)"></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">
You have to make <input name="fireoutput"> fires!
</form>
</td>
</tr>
</table>
<br>
<br>
<table cellspacing="2" cellpadding="0">
<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="form">
Enter in the experience you would like: <input name="wood1">
<br>
Enter in your woodcutting experience: <input name="wood2">
<br>
<center><input type="button" value="Submit" onclick="calcwood(this.form)"></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">
You have to cut <input name="woodoutput"> regular trees!
<!--the answer to the equation is outputted here--//>
</form>
</td>
</tr>
</table>
</body>
</html>
The first form is working great, but i want alot of those form s for different purposes on one page. Can anyone help me out here?
<html>
<head>
<style>
INPUT {
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 10px;
border: 1px green solid;
background-color: #000000;
color: green;
}
</style>
</head>
<body>
<script language=javascript>
function calc(f){
var num1 = f.fire1.value;
var num2 = f.fire2.value;
var num3 = f.fire3.value;
if (isNaN(num1)){
alert("Number 1 must be numeric.");
f.fire1.focus();
return;
}
else if (isNaN(num2)){
alert("Number 2 must be numeric.");
f.fire2.focus();
return;
}
else if (isNaN(num3)){
alert("Number 3 must be numeric.");
f.fire3.focus();
return;
}
else if (num3=="0"){
alert("Number 3 must not be zero.");
f.fire3.focus();
return;
}
f.fireoutput.value = (num1-num2)/num3;
}
</script>
<script language=javascript>
function calcwood(f){
var num1 = f.wood1.value;
var num2 = f.wood2.value;
var num3 = f.wood3.value;
if (isNaN(num1)){
alert("Number 1 must be numeric.");
f.fire1.focus();
return;
}
else if (isNaN(num2)){
alert("Number 2 must be numeric.");
f.fire2.focus();
return;
}
f.woodoutput.value = (num1-num2)/num3;
}
</script>
<table cellspacing="2" cellpadding="0">
<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="form">
Enter in the experience you would like: <input name="fire1">
<br>
Enter in your firemaking experience: <input name="fire2">
<br>
Enter in how much exp. you get per fire: <input name="fire3">
<center><input type="button" value="Submit" onclick="calc(this.form)"></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">
You have to make <input name="fireoutput"> fires!
</form>
</td>
</tr>
</table>
<br>
<br>
<table cellspacing="2" cellpadding="0">
<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="form">
Enter in the experience you would like: <input name="wood1">
<br>
Enter in your woodcutting experience: <input name="wood2">
<br>
<center><input type="button" value="Submit" onclick="calcwood(this.form)"></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">
You have to cut <input name="woodoutput"> regular trees!
<!--the answer to the equation is outputted here--//>
</form>
</td>
</tr>
</table>
</body>
</html>
The first form is working great, but i want alot of those form s for different purposes on one page. Can anyone help me out here?