Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to calculate cumulative marks in a pdf field?

Participant ,
Dec 14, 2016 Dec 14, 2016

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?

TOPICS
PDF forms
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Dec 18, 2016 Dec 18, 2016

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;

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 14, 2016 Dec 14, 2016

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 14, 2016 Dec 14, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 14, 2016 Dec 14, 2016

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 17, 2016 Dec 17, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2016 Dec 18, 2016

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 18, 2016 Dec 18, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2016 Dec 18, 2016

Works just fine for me. Did you copy the code into Word or something like that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 18, 2016 Dec 18, 2016

Press Ctrl+J and see if there are any error messages there.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 18, 2016 Dec 18, 2016
LATEST

Thanks for the reply.

It perfectly works for me. Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines