Copy link to clipboard
Copied
I prepare a question paper in acrobat pro. Each ques has check box for correct & incorrect answer. It has a totalmarks field & each quesmark field. What I am trying to do, when a person ticks correct answer check box of any ques then his/her cumulative marks will show in total marks field. I want to implement this for all 10 question of my paper.
Can anybody please help?
Copy link to clipboard
Copied
OK, then you can use this script as the custom calculation of the total marks field:
var totalCorrect = 0;
for (var i=1; i<=10; i++) {
if (this.getField("correctq"+i).value!="Off") totalCorrect++;
}
event.value = Number(this.getField("questionmark").value) * totalCorrect;
Copy link to clipboard
Copied
Your description is not very clear... Do you have a check-box that says whether or not the question was answered correctly, or do you have multiple check-boxes which are the answers for the question, and the user selects one of them?
Also, what are the names of the fields involved?
Copy link to clipboard
Copied
Thanks for reply.
I have two check-boxes named "correct" & "incorrect" for each question. Other field are "questionmark" & "totalmarks". From which user will select one of them. If user select "correct" field then it would be "correct" * "questionmark" and result will populate in total marks field.
rgds
Copy link to clipboard
Copied
So there's a single "questionmark" field, or one for each question?
Also, you still didn't specify what are the names of the check-box fields...
Copy link to clipboard
Copied
Thanks for the reply
For correct question I have check boxes named (“correctq1”, “correctq2”, “correctq3”, “correctq4”, “correctq5”, “correctq6”, “correctq7”, “correctq8”, “correctq9”, “correctq10”)
For incorrect question I have ckeck boxes named (“incorrectq1”, “incorrectq2”, “incorrectq3”, “incorrectq4”, “incorrectq5”, “incorrectq6”, “incorrectq7”, “incorrectq8”, “incorrectq9”, “incorrectq10”)
For all questions I have only one “questionmark” field.
Rgds
Copy link to clipboard
Copied
OK, then you can use this script as the custom calculation of the total marks field:
var totalCorrect = 0;
for (var i=1; i<=10; i++) {
if (this.getField("correctq"+i).value!="Off") totalCorrect++;
}
event.value = Number(this.getField("questionmark").value) * totalCorrect;
Copy link to clipboard
Copied
Thanks for reply.
WhenI try, it shows SyntaxError:illegal character3:at line 4.
When I use below code
var totalCorrect = 0;
for (var i=1; i<=10; i++) {
if (this.getField("correctq"+i).value!="Off") totalCorrect++;
}
event.value =
Number((this.getField("questionmark").value) * totalCorrect);
No error shows. In this case if I check or uncheck any checkbox no change in "totalmarks" field whether I change "questionmark" fields value then "totalmarks" fields value changes.
Rgds
Copy link to clipboard
Copied
Works just fine for me. Did you copy the code into Word or something like that?
Copy link to clipboard
Copied
Press Ctrl+J and see if there are any error messages there.
Copy link to clipboard
Copied
Thanks for the reply.
It perfectly works for me. Thanks again.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more