Thomas Turner
asked on
Javascript and XHTML building a calculator
What I’m trying to do,
I have 3 classes and each class has a drop down list of A, B, C, D, F and each letter corresponds with a number 1-4. + a place to put your name
I need to finger out how to do this
When you click My GPA I need it to add all the numbers up and divide them by 3 and output that and you name on another page.
I’m very new to JavaScript
I have 3 classes and each class has a drop down list of A, B, C, D, F and each letter corresponds with a number 1-4. + a place to put your name
I need to finger out how to do this
When you click My GPA I need it to add all the numbers up and divide them by 3 and output that and you name on another page.
I’m very new to JavaScript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GPA Calculator</title
<script type="text/javascript">
<!--
function GPA(name, GPA)
{
GPA = ParseInt(GPA)
Class1 = parseInt(Class1);
Class2 = parseInt(Class2);
Class3 = parseInt(Class3);
var sum = (Class1 + Class2 + Class3)/(3);
var str = "<h4>" + name + "</h4><p> Your GPA is " + sum + ".</p>;
document.write(str);
}
//-->
</script>
</head>
<body>
<form>
<p>GPA Calculator</p>
<p>Name:
<input name="name" type="text" id="name" size="20" maxlength="20" />
</p>
<table>
<tr>
<td>Class 1</td>
<td>
<select name="Class1">
<option value="4">A</option>
<option value="3">B</option>
<option value="2">C</option>
<option value="1">D</option>
<option value="0">F</option>
</select>
</form>
</td>
</tr>
<tr>
<td>Class 2</td>
<td>
<select name="2">
<option value="4">A</option>
<option value="3">B</option>
<option value="2">C</option>
<option value="1">D</option>
<option value="0">F</option>
</select>
</form>
</td>
</tr>
<tr>
<td>Class 3</td>
<td>
<select name="Class3">
<option value="4">A</option>
<option value="3">B</option>
<option value="2">C</option>
<option value="1">D</option>
<option value="0">F</option>
</select>
</form></td>
</tr>
</table>
<p>
<input type="button" value="My GPA" onclick="GPA(this.form.name.value,this.form.GPA.value)" />
</p>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The GPA field that you tried to get a value from with this code : this.form.GPA.value
ASKER
0/*this field does not exist:
what field is it talking about?
Thank you all for your help.