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

Custom Script for PDF form: multiple activated checkboxes adds text to a textbox

Community Beginner ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

I am a teacher and use PDF-forms to give a mark for digital things, the students had to send me. I start with word, create the standard of evaluation and transform it into a pdf-form. This form consists of checkboxes which are checked by me, if an aspect of the given task is successfully made in the work of the student. I set the checkboxes to give back a value of 1, so I can calculate the textboxes for the points (Pkt.), beeing the sum of checkbox x to z. Easy. But I often want to give just one point, if a specific amount of checkboxes are activated, otherwhise it's 0 points.

Unfortunately there is no construction kit in the settings of an if-then-else or other functions. I mean ... the premade functions like "sum of ..." or "product of ..." etc. are good and satisfy the majority of my needs. But the Java-Editor is so horrible ... I tried to create the fuction in another Java-editor and paste it into the "custom calculation script"-field, but it doesn't work at all. Please help me!

Concrete: I want in this form, that if all 8 checkboxes from Check Box 1.0 to Check Box 1.7 are checked, the textfield "Punkte 1.0" (points of task 1) gives back 1, else 0.

 

Screenshot 2022-07-03 182521.png

TOPICS
JavaScript , PDF forms

Views

685

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Jul 03, 2022 Jul 03, 2022

As 'Custom calculation script' of "Punkte 1.0" field use this:

var total = 0;
for(var i=0; i<=7; i++){
if(this.getField("Check Box1."+i).valueAsString != "Off")total++;}
if(total == 8)event.value = 1;
else
event.value = 0;

Votes

Translate

Translate
Community Beginner ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

I am using Adobe Acrobat Pro DC, (Version 2022.001.20142, but automatically updating)

Votes

Translate

Translate

Report

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 ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

As 'Custom calculation script' of "Punkte 1.0" field use this:

var total = 0;
for(var i=0; i<=7; i++){
if(this.getField("Check Box1."+i).valueAsString != "Off")total++;}
if(total == 8)event.value = 1;
else
event.value = 0;

Votes

Translate

Translate

Report

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 Beginner ,
Jul 03, 2022 Jul 03, 2022

Copy link to clipboard

Copied

LATEST

OMG, that was fast and correct! Thank you so much!

Votes

Translate

Translate

Report

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