Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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!!!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now