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

Average Rating Formula - Help

New Here ,
Jul 27, 2022 Jul 27, 2022

I am trying to write a formula to calculate the average rating on a form, but I do not speak Java. I asked a co-worker for help and they gave me the following formula, but it is not working... Please help! 

 

var avgScore = 0;

var score1 = document.getElementById('Text2').value;
var score2 = document.getElementById('Text3').value;
var score3 = document.getElementById('Text4').value;
var score4 = document.getElementById('Text5').value;
var score5 = document.getElementById('Text6').value;

avgScore = (score1 + score2 * 2 + score3 * 3 + score4 * 4 + score5 * 5) / (score1 + score2 + score3 + score4 + score5);

Text1.value = avgScore;

 

 

I really have no clue here guys! Any help is appreciated! 

TOPICS
How to , JavaScript , PDF forms
578
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 ,
Jul 28, 2022 Jul 28, 2022

Replace this:

var score1 = document.getElementById('Text2').value;

with this:

var score1 = Number(this.getField("Text2").value);

if you use script in "Text1" field as custom calculation replace Text1.value with event.value.

You sure thats the formula you want to use to calculate average?

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 ,
Jul 28, 2022 Jul 28, 2022
  1.  Acrobat uses Javascript, not Java
  2.  You can't use browser Javascript in Acrobat.
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
New Here ,
Jul 29, 2022 Jul 29, 2022
LATEST

All that is Greek to me. As I said, I really have NO clue. I am good at working with Microsoft apps, but I have just started developing forms in Adobe. I have zero IT knowledge and have never taken a class, nor have I ever been trained in Adobe. I know enough to be dangerous. I would LOVE the opportunity to learn more though! 

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

Replace this:

var score1 = document.getElementById('Text2').value;

with this:

var score1 = Number(this.getField("Text2").value);

if you use script in "Text1" field as custom calculation replace Text1.value with event.value.

You sure thats the formula you want to use to calculate average?

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
New Here ,
Jul 29, 2022 Jul 29, 2022

I am not sure. This is what was suggested to me. It's not just a simple average. It is the average of a rating scale of 1-5 (unsatisfactory, needs improvement, above average, exceeds standards). 

But it does work with your fixes!!! Thank you SOOOO much!!! 

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