Menu
I’m trying to write a simple grade calculator for my students to post on my webpage…
Basically it should look like this:
What is your goal mark (%)? ________
What is your final term mark (%)? ________
_______% is what you need to score on the final exam to reach your goal mark.
Students should be able to fill in the first two blanks and click a calculate button so the script can fill in the third blank.
The script needs to calculate the mark this way:
((goal mark – term mark)*3)+term mark)=exam mark
Thanks for your help!
[code=html]
<form action='#' onsubmit='findscore(); return false;'>
<p>Goal Mark: <input id='goal' type='number' max='100' min='0'></p>
<p>Term Mark: <input id='term' type='number' max='100' min='0'></p>
<p>Exam Mark: <input id='exam' type='number' disabled='disabled'></p>
<p><input type='submit' value='find exam score needed'></p>
</form>[/code]
[code=php]<script type='text/javascript'>
<![CDATA[
function findscore(){
var g = parseInt("0"+document.getElementById('goal').value, 10);
g = (g > 100)?100:g;
var t = parseInt("0"+document.getElementById('term').value, 10);
t = (t > 100)?100:t;
var e = document.getElementById('exam');
e.value = (g - t)*3+t;
};
]]>
</script>[/code]
[code=html]<script type='text/javascript'>
/* <![CDATA[ */
function findscore(){
var g = parseInt("0"+document.getElementById('goal').value, 10);
g = (g > 100)?100:g;
var t = parseInt("0"+document.getElementById('term').value, 10);
t = (t > 100)?100:t;
var e = document.getElementById('exam');
e.value = (g - t)*3+t;
};
/* ]]> /*
</script>[/code]
[CODE]
<!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" dir="ltr">
<head>
<title>Calculating Target Grades</title>
<script type='text/javascript'>
/* <![CDATA[ */
function findscore(){
var g = parseInt("0"+document.getElementById('goal').value, 10);
g = (g > 100)?100:g;
var t = parseInt("0"+document.getElementById('term').value, 10);
t = (t > 100)?100:t; var e = document.getElementById('exam');
e.value = (g - t)*3+t;
};
/* ]]> */
</script>
</head>
<body>
</p>
<form action='#'>
<p>Goal Mark: <input id='goal' type='number' max='100' min='0'></p>
<p>Term Mark: <input id='term' type='number' max='100' min='0'></p>
<p>Exam Mark: <input id='exam' type='number' disabled='disabled'></p>
<p><input type='button' onClick='findscore()' value='find exam score needed'></p>
</form>
</p>
</body>
</html>
[/CODE]
[code=html]<!DOCTYPE html5>
<html>
<head>
<title>Calculating Target Grades</title>
<script type='text/javascript'>
/* <![CDATA[ */
function findscore(){
var g = parseInt("0"+document.getElementById('goal').value, 10);
g = (g > 100)?100:g;
var t = parseInt("0"+document.getElementById('term').value, 10);
t = (t > 100)?100:t;
var e = document.getElementById('exam');
e.value = (g - t)*3+t;
};
/* ]]> */
</script>
</head>
<body>
<form action='#'>
<p>Goal Mark: <input id='goal' type='number' max='100' min='0'></p>
<p>Term Mark: <input id='term' type='number' max='100' min='0'></p>
<p>Exam Mark: <input id='exam' type='number' disabled='disabled'></p>
<p><input type='button' onClick='findscore()' value='find exam score needed'></p>
</form>
</body>
</html>[/code]
0.1.9 — BETA 5.28