I am trying to build a calculator with radio buttons. I keep getting a $NaN error in the display field.
When I use one radio button without the "" around the value it works. When I add the other buttons it gives me the error.
Here is the code:
By the way, how do you post the code in those cool code boxes?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Calculator with Radio Buttons</title>
</head>
<script language='javascript'>function compute(form){
form.totalCost.value ="$" + form.shirtNum.value * form.shirtPrice.value;
}
</script>
<body>
<form method="post">
<p>ShirtNum
<input type="text" name="shirtNum" size="10">
</p>
<p>ShirtPrice
<label>
<input type="radio" name="shirtPrice" value="15">
$15</label>
<label>
<input type="radio" name="shirtPrice" value="20">
$20
</label>
<br>
</p>
<p>TotalCost
<input TYPE="text" NAME="totalCost" SIZE="10">
</p>
<p>
<input TYPE="button" VALUE="Compute Results" ONCLICK="compute(this.form)">
</p>
</form>
</body>
</html>
I'd gladly pay you on Thursday
for a hamburger today!
When I use one radio button without the "" around the value it works. When I add the other buttons it gives me the error.
Here is the code:
By the way, how do you post the code in those cool code boxes?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Calculator with Radio Buttons</title>
</head>
<script language='javascript'>function compute(form){
form.totalCost.value ="$" + form.shirtNum.value * form.shirtPrice.value;
}
</script>
<body>
<form method="post">
<p>ShirtNum
<input type="text" name="shirtNum" size="10">
</p>
<p>ShirtPrice
<label>
<input type="radio" name="shirtPrice" value="15">
$15</label>
<label>
<input type="radio" name="shirtPrice" value="20">
$20
</label>
<br>
</p>
<p>TotalCost
<input TYPE="text" NAME="totalCost" SIZE="10">
</p>
<p>
<input TYPE="button" VALUE="Compute Results" ONCLICK="compute(this.form)">
</p>
</form>
</body>
</html>
I'd gladly pay you on Thursday
for a hamburger today!