vanan4u
IS-IT--Management
- Feb 26, 2012
- 3
i've created a set of online questionnaire and writing javascript to calculate the percentage.there are 12 questions with answer choice from 0-6. the below code is written to do calculation but because this is an online questionnaire i need to use get element by id to do it.i m not very sure how to do it..anyone can help me..thanks
//html codes <form name =myform method="post" action="">
var numOfGroups = 12;
function calc() {
var score = 0;
for (var j=1; j<=numOfGroups; j++) {
var f = document["myform"]["ques"+j];
for (var i=0; i<f.length; i++) {
if (f.checked) {
score += Number(f.value /72 *100);
}
}
}
alert ("Your Score is " + score);
return false;
</script
//html codes <form name =myform method="post" action="">
var numOfGroups = 12;
function calc() {
var score = 0;
for (var j=1; j<=numOfGroups; j++) {
var f = document["myform"]["ques"+j];
for (var i=0; i<f.length; i++) {
if (f.checked) {
score += Number(f.value /72 *100);
}
}
}
alert ("Your Score is " + score);
return false;
</script