I was told to do this in a class. This code doesn't work like the teacher says it should. The problem is that it is suppose to add the text boxes together and total it in a final total text box. please help!
<script Language="javascript">
<!--This Javascript was created by Matthew Horner-->
function do_addition()
{
var lab1,lab2,test1,test2, final, cp;
lab1=document.form1.Lab1Score.value;
lab2=document.form1.Lab2Score.value;
test1=document.form1.Test1Score.value;
test2=document.form1.Test2Score.value;
final=document.form1.FinalScore.value;
cp=document.form1.Classparticipationscore.value;
alert("The Value of Lab 1 is "+lab1+" so I got to the function")
alert("The Value of Lab 2 is "+lab2+" so I got to the function")
alert("The Value of Test 1 is "+test1+" so I got to the function")
alert("The Value of Test 2 is "+test2+" so I got to the function")
alert("The Value of Final is "+final+" so I got to the function")
alert("The Value of Class Participation is "+cp+" so I got to the function")
alert("The Value of Total Score is "+total+" so I got to the function")
if (result >=405 && result<=450) {alert("Total Points of "+result+" gives you an A")}
if (result >=360 && result<=404) {alert("Total Points of "+result+" gives you an B")}
if (result >=292 && result<=359) {alert("Total Points of "+result+" gives you an C")}
if (result >=247 && result<=291) {alert("Total Points of "+result+" gives you an D")}
if (result >=0 && result<=246) {alert("Total Points of "+result+" gives you an F")}
}
2) someone to sit down, correct the code for you and post the correct error free code for you to take to class.
If it's 1) then go to line 34 and the syntax error is very obvious. If you can't find it, then post just line 34 as you see it to ensure we are both looking at the same line number.
no offence - but you will be hard pressed to convince me you can't see anything wrong in that line 34. (btw - that line is as I se it as well)
If you genuinely can't see the syntax error, then to be honest I suspect you didn't write the code but most probably copied and pasted it from somewhere because the error sticks out like the proverbial sore thumb.
This is the correct code that I have already on my computer.
result=parseFloat(lab1)+parseFloat(lab2)+parseFloat(test1)+parseFloat(test2)+parseFloat(cp)+parseFlo at(final);
nup sorry - I'm not convinced you are being totally truthful here because you said DW sees it as an error since you said it generates a syntax error at line 34 and so the copy and paste is ok.
hopefully someone else will come along to help you
Thanks for the help. I don't understand what is wrong and I did exactly what my teacher wanted me and my class to do. I copied it word for word and I guess I just don't see it. Hopefully someone can help. Thanks for your time.
Bookmarks