View Full Version : Now what's the problem?
Antoniohawk
09-25-2002, 01:10 AM
<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(fire1,fire2,fire3,fireoutput){
var num1 = fire1.value;
var num2 = fire2.value;
var num3 = fire3.value;
if (isNaN(num1)){
alert("Number 1 must be numeric.");
fire1.focus();
return;
}
else if (isNaN(num2)){
alert("Number 2 must be numeric.");
fire2.focus();
return;
}
else if (isNaN(num3)){
alert("Number 3 must be numeric.");
fire3.focus();
return;
}
else if (num3=="0"){
alert("Number 3 must not be zero.");
fire3.focus();
return;
}
fireoutput.value = (num1-num2)/num3;
}
function calc(wood1,wood2,woodoutput){
var num1 = wood1.value;
var num2 = wood2.value;
if (isNaN(num1)){
alert("Number 1 must be numeric.");
wood1.focus();
return;
}
else if (isNaN(num2)){
alert("Number 2 must be numeric.");
wood2.focus();
return;
}
woodoutput.value = (num1-num2)/25;
}
</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.fire1,this.form.fire2,this.form.fire3,this.form.fireoutput)"></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>
<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="woodform">
Enter in the experience you would like: <input name="wood1">
<br>
Enter in your firemaking experience: <input name="wood2">
<br>
<center><input type="button" value="Submit" onclick="calc(this.form.wood1,this.form.wood2,this.form.wood3,this.form.woodoutput)"></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="woodoutput"> fires!
</form>
</td>
</tr>
</table>
glenngv
09-25-2002, 03:24 AM
cross-posted here http://codingforums.com/showthread.php?threadid=6684
dont start a new thread so that others can follow the discussion. That way more people may be able to help you.
back to the topic at hand.
as i looked at your new code, the formula for wood had changed. so i had to change again the implemention.
here's the full code, just copy and paste it:
<html>
<head>
<style>
INPUT {
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 10px;
border: 1px green solid;
background-color: #000000;
color: green;
}
</style>
<script language=javascript>
function calcFire(in1,in2,in3,out){
var num1 = parseInt(in1.value,10);
var num2 = parseInt(in2.value,10);
var num3 = parseInt(in3.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;
}
if (isNaN(num3) || num3<1){
alert("Please enter a non-zero positive number for field 3.");
in3.focus();
return;
}
out.value = (num1-num2)/num3;
}
function calcWood(in1,in2,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)/25;
}
</script>
</head>
<body>
<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="fireform">
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="calcFire(this.form.fire1,this.form.fire2,this.form.fire3,this.form.fireoutput)"></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>
<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="woodform">
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.wood1,this.form.wood2,this.form.woodoutput)"></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="woodoutput"> fires!
</form>
</td>
</tr>
</table>
</body>
</html>
Antoniohawk
09-25-2002, 10:58 PM
i know u are just waiting to help me again Glenn. Here is your next task if you choose to accept it. The code you made for me is great. I just want to make a few additions. At the moment, the wood is worth 25 experience. I want to be able to choose from a drop down list, the kind of wood and when i choose the type of wood i want the value of its experience to change. Make up some names of wood and show me where to enter in its experience. Another thing, can i make it so that where it says "You have to cut <input name="woodoutput"> regular logs!", change regular to the name of the log when u select it in the dropdown? THX alot glenn (thaking in advance cuz i know u can help me) .
glenngv
09-26-2002, 02:04 AM
<html>
<head>
<style>
INPUT {
FONT-FAMILY: Verdana, Helvetica;
FONT-SIZE: 10px;
border: 1px green solid;
background-color: #000000;
color: green;
}
</style>
<script language=javascript>
function calcFire(in1,in2,in3,out){
var num1 = parseInt(in1.value,10);
var num2 = parseInt(in2.value,10);
var num3 = parseInt(in3.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;
}
if (isNaN(num3) || num3<1){
alert("Please enter a non-zero positive number for field 3.");
in3.focus();
return;
}
out.value = (num1-num2)/num3;
}
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">
<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="fireform">
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="calcFire(this.form.fire1,this.form.fire2,this.form.fire3,this.form.fireoutput)"></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>
<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="woodform">
Enter in the experience you would like: <input name="wood1">
<br>
Enter in your woodcutting experience: <input name="wood2">
<br>
Enter the type of wood:
<select name="woodtype">
<option value="25">type 1</option>
<option value="50">type 2</option>
<option value="100">type 3</option>
<option value="150">type 4</option>
</select>
<br>
<center><input type="button" value="Submit" onclick="calcWood(this.form.wood1,this.form.wood2,this.form.woodtype,this.form.woodoutput)"></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="woodoutput"> fires!
</form>
</td>
</tr>
</table>
</body>
</html>
just change the type and the corresponding value in the woodtype select tag
Antoniohawk
09-26-2002, 02:45 AM
You've done it again Glenn. Thx alot.
Antoniohawk
10-04-2002, 06:32 PM
Time for more debugging Glenn.
<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(wood1,wood2,regularoutput,willowoutput,mapleoutput,yewoutput,magicoutput){
var num1 = parseInt(wood1.value,10);
var num2 = parseInt(wood2.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;
}
regularoutput.value = (num1-num2)/25;
oakoutput.value = (num1-num2)/37.5;
willowoutput.value = (num1-num2)/62.5;
mapleoutput.value = (num1-num2)/100;
yewoutput.value = (num1-num2)/175;
magicoutput.value = (num1-num2)/250;
}
</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 woodcutting 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>
</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="regularoutput"> regular trees!
<br>
You have to cut <input name="oakoutput"> oak trees!
<br>
You have to cut <input name="willowoutput"> willow trees!
<br>
You have to cut <input name="mapleoutput"> maple trees!
<br>
You have to cut <input name="yewoutput"> yew trees!
<br>
You have to cut <input name="magicoutput"> magic trees!
</form>
</td>
</tr>
</table>
</body>
</html>
mordred
10-04-2002, 10:00 PM
You want to include the error messages you received or aptly describe what you want to have modified so glenngv doesn't have to figure out everything on his own, don't you? ;)
whammy
10-05-2002, 01:25 AM
Before I asked for glenngv's help (because I'm sure he's a busy man, and I know he's a smart one), I would attempt debugging it yourself.
"Time for more debugging Glenn." sounds more like a demand than a request for scripting help. ;)
Antoniohawk
10-05-2002, 03:45 AM
I admit that I have kind of been a jerk, and I'm sry about that. Here's the deal, I never really got down the basics of JavaScript, so I cant really make anything usefull without almost the complete help of some1. That's pretty pathetic, I know. If anyone has a good suggestion of a tutorial site, then please post it here.
Sry again and Thank You in advance for the tutorial list
chrismiceli
10-05-2002, 04:18 AM
adios recommends www.webmonkey.com as for me i would say get a book like i did, i got my really good book for 4 bucks at a thrift shop, just look around
whammy
10-07-2002, 01:08 PM
Actually, I'll second that webmonkey recommendation. Thau's javascript tutorial is an excellent start. Then you'll want to check out the tutorials on www.javascriptkit.com too.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.