Problem with a check box form

Feb 21, 2018

Copy link to clipboard

Copied

Hi Guys

I have created a form with 20 check boxes  each check box is named vital signs 1-20 what I have managed to do is add up all the check boxes and display the answer as a percentage using the following:

var total = 0;

for (var i=1; i<=20; i++) {

if (this.getField("vital signs "+i).value!="Off") total++;}

event.value = total/20;

my problem is that if 2 particular check boxes (Vital signs 3 & Vital signs 6) if either is not ticked then the percentage total  needs to be 0% but if they are both ticked then the true percentage for all 20 check boxes needs to be displayed

also if the percentage is less then 80% the total box needs to be red

please can anyone help

To handle special conditions, just add a conditional.

if((this.getField("vital signs 3").value=="Off") || (this.getField("vital signs 6").value=="Off"))

{

  event.value = 0;

}

else

{

   var total = 0;

   for (var i=1; i<=20; i++) {

         if (this.getField("vital signs "+i).value!="Off") total++;

    }

    event.value = total/20;

}

// this bit really belongs in a format event, but it works here in the calculation just fine.

event.target.strokeColor = (event.value<.8)?color.red:color.black;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

65

Likes

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

Problem with a check box form

Feb 21, 2018

Copy link to clipboard

Copied

Hi Guys

I have created a form with 20 check boxes  each check box is named vital signs 1-20 what I have managed to do is add up all the check boxes and display the answer as a percentage using the following:

var total = 0;

for (var i=1; i<=20; i++) {

if (this.getField("vital signs "+i).value!="Off") total++;}

event.value = total/20;

my problem is that if 2 particular check boxes (Vital signs 3 & Vital signs 6) if either is not ticked then the percentage total  needs to be 0% but if they are both ticked then the true percentage for all 20 check boxes needs to be displayed

also if the percentage is less then 80% the total box needs to be red

please can anyone help

To handle special conditions, just add a conditional.

if((this.getField("vital signs 3").value=="Off") || (this.getField("vital signs 6").value=="Off"))

{

  event.value = 0;

}

else

{

   var total = 0;

   for (var i=1; i<=20; i++) {

         if (this.getField("vital signs "+i).value!="Off") total++;

    }

    event.value = total/20;

}

// this bit really belongs in a format event, but it works here in the calculation just fine.

event.target.strokeColor = (event.value<.8)?color.red:color.black;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

66

Likes

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
Feb 21, 2018 0
Feb 21, 2018

Copy link to clipboard

Copied

To handle special conditions, just add a conditional.

if((this.getField("vital signs 3").value=="Off") || (this.getField("vital signs 6").value=="Off"))

{

  event.value = 0;

}

else

{

   var total = 0;

   for (var i=1; i<=20; i++) {

         if (this.getField("vital signs "+i).value!="Off") total++;

    }

    event.value = total/20;

}

// this bit really belongs in a format event, but it works here in the calculation just fine.

event.target.strokeColor = (event.value<.8)?color.red:color.black;

Likes

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
Reply
Loading...
Feb 21, 2018 0
Feb 21, 2018

Copy link to clipboard

Copied

thanks Tom that works great I appreciate your help

Likes

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
Reply
Loading...
Feb 21, 2018 0