Menu
I need help with this quiz I have it working and everything but I want the points to be calculated up when you press submit and go to the results page. so I guess the question is (I read the sticky) How do I calculate the exact score with the certain javascript that I am using?
I have a zip file for you to download the files in. All the javascript is embedded into the main quiz with the questions and such. And the other pages are just result pages.
[url]http://www.gregmaustin.com/uhcl/Student_Quiz.zip
[CODE]
<script language="JavaScript" type="text/javascript">
<!--Hide JavaScript from Java-Impaired Browsers
function test_it(entry) {
if (entry.value!=null && entry.value.length!=0) {
entry.value=""+ eval(entry.value);
}
computeForm(entry.form);
}
function computeForm(form) {
var total=0
for (var count=0; count<4; count++)
{
if (form.a[count].checked){
var total=total+parseInt(form.a[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.b[count].checked){
var total=total+parseInt(form.b[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.c[count].checked){
var total=total+parseInt(form.c[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.d[count].checked){
var total=total+parseInt(form.d[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.e[count].checked){
var total=total+parseInt(form.e[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.f[count].checked){
var total=total+parseInt(form.f[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.g[count].checked){
var total=total+parseInt(form.g[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.h[count].checked){
var total=total+parseInt(form.h[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.i[count].checked){
var total=total+parseInt(form.i[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.j[count].checked){
var total=total+parseInt(form.j[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.k[count].checked){
var total=total+parseInt(form.k[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.l[count].checked){
var total=total+parseInt(form.l[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.m[count].checked){
var total=total+parseInt(form.m[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.n[count].checked){
var total=total+parseInt(form.n[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.o[count].checked){
var total=total+parseInt(form.o[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.p[count].checked){
var total=total+parseInt(form.p[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.q[count].checked){
var total=total+parseInt(form.q[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.r[count].checked){
var total=total+parseInt(form.r[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.s[count].checked){
var total=total+parseInt(form.s[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.t[count].checked){
var total=total+parseInt(form.t[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.u[count].checked){
var total=total+parseInt(form.u[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.v[count].checked){
var total=total+parseInt(form.v[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.w[count].checked){
var total=total+parseInt(form.w[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.x[count].checked){
var total=total+parseInt(form.x[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.y[count].checked){
var total=total+parseInt(form.y[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.z[count].checked){
var total=total+parseInt(form.z[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.aa[count].checked){
var total=total+parseInt(form.aa[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.bb[count].checked){
var total=total+parseInt(form.bb[count].value);
}
}
for (var count=0; count<4; count++)
{
if (form.cc[count].checked){
var total=total+parseInt(form.cc[count].value);
}
}
if (total<0){window.location="results1.html" }
else if (total<30){window.location="results2.html" }
else if (total<60){window.location="results3.html" }
else if (total<90){window.location="results4.html" }
else {window.location="results5.html" }
}
//-->
</script>
[/CODE]
[CODE]
<head>
<script>
function checkTotal() {
var url = location.href;
url = url.toString();
var urlArray = url.split("?");
var total = urlArray[1];
document.getElementById("screentotal").innerHTML= total;
}
window.onload = checkTotal; // run the script after the html is loaded
</script>
</head>
<body>
<p id="screentotal"></p>
</body>
[/CODE]
[CODE]
<script>
function checkTotal() {
var url = location.href;
url = url.toString();
var urlArray = url.split("?");
var total = urlArray[1];
document.getElementById("screentotal").innerHTML= total;
}
window.onload = checkTotal; // run the script after the html is loaded
</script>
[/CODE]
[CODE]<script>
function checkTotal() {
var url = location.href;
url = url.toString();
var urlArray = url.split("?");
var total = urlArray[1];
document.getElementById("screentotal").innerHTML= total;
}
window.onload = checkTotal; // run the script after the html is loaded
</script>[/CODE]
var url = "results2.html" + "?" + total;
window.location=url;
var url = "results2.html" + "?" + total;
window.location=url;
var url = "results2.html" + "?" + total;
window.location=url;
var url = "results2.html" + "?" + total;
window.location=url;
var url = "results2.html" + "?" + total;
window.location=url;
var url = "results2.html" + "?" + total;
window.location=url;
var url = "results2.html" + "?" + total;
window.location=url;
var url = "results2.html" + "?" + total;
window.location=url;
if (total<30){window.location="results2.html" }
else if (total<60){window.location="results3.html" }
else if (total<90){window.location="results4.html" }
else {window.location="results4.html" }
url = "results4.html" + "?" + total;
window.location=url;
url = "results3.html" + "?" + total;
window.location=url;
url = "results2.html" + "?" + total;
window.location=url; /* it is only listening to this one. I guess I need to state what range i want it to go too if it goes to this one and the range on going to any other pages. but i dont know how? */
}[/QUOTE]
0.1.9 — BETA 5.20