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

Help to change excel formula to java script

New Here ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

Please will someone help me change this over:

 

=IF(A1<30,"Inadequate",IF(A1<60,"Requires_Improvement",IF(A1<90,"Good",IF(A1>=90,"Outstanding"))))

 

Also, Im new to using formula's in Adobe- can anyone recommend where I can learn?

TOPICS
JavaScript

Views

814

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 , Jun 04, 2021 Jun 04, 2021

Open the properties of the field that should display the text and go to the "Calculate" tab, then select to create a custom calculation script and uses the following (slighly modified from above): 

 

var res = "";
var a1 = this.getField("A1").value;
if (a1 == "") {
    res = "";
}
else if (a1 < 30) {
    res = "Inadequate";
}
else if (a1 < 60) {
    res = "Requires_Improvement";
}
else if (a1 < 90) {
    res = "Good";
}
else if (a1 >= 90) {
    res = " Outstanding";
}
else {
    res = "Error";
}
...

Votes

Translate

Translate
Community Expert ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

I think you are trying to do this:

 

 

var res = "";
var a1 = this.getField("A1").value;
if (a1 < 30) {
    res = "Inadequate";
}
else if (a1 < 60) {
    res = "Requires_Improvement";
}
else if (a1 < 90) {
    res = "Good";
}
else if (a1 >= 90) {
    res = " Outstanding";
}
else {
    res = "Error";
}

 

 

As far as learning JavaScript goes, take a look here: http://khkonsulting.com/2017/01/learning-to-program-javascript-for-adobe-acrobat/

 

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
New Here ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

Thank you, it doesnt seem to kick it out as not working, but it doesnt seem to do anything either - the box just stays blank...any ideas? Thanks again

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 ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

The script relies on a field that has the name A1, but more importantly, how do you want to use it? You need to add more to the script, depending on the context you want to use it in. I assumed the question was just about the complexity of the if/else statement.
So again, how do you want to use the script? 

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
New Here ,
Jun 04, 2021 Jun 04, 2021

Copy link to clipboard

Copied

Thank you. 

 

I want to take a test paper, add up the points, convert the amount of points into a percentage and then from that percentage depending on what the percentage is grade them as inadequte, needs improvement, good, outstanding. 

 

Currently on each question there is a 'points earned' box. 

 

This automatically all gets added up and put into a 'total point score' box. 

 

From the total points score box there is another box which is a percentage box, this box takes the total from 'total score' and converts into a percentage. 

 

Now i have grade box. I want to use java script to make this box automatically change based on the figure in the percentage box. 

 

If the percentage is less than 30- inadequate 

If the percentage is less than 60- requires improvement

If percentage is less than 90- good

Anything 90 and above is outstanding.

 

Is it possible to do this do you think?

 

Thank you so much for all your help!

 

 

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 ,
Jun 04, 2021 Jun 04, 2021

Copy link to clipboard

Copied

Open the properties of the field that should display the text and go to the "Calculate" tab, then select to create a custom calculation script and uses the following (slighly modified from above): 

 

var res = "";
var a1 = this.getField("A1").value;
if (a1 == "") {
    res = "";
}
else if (a1 < 30) {
    res = "Inadequate";
}
else if (a1 < 60) {
    res = "Requires_Improvement";
}
else if (a1 < 90) {
    res = "Good";
}
else if (a1 >= 90) {
    res = " Outstanding";
}
else {
    res = "Error";
}

event.value = res;

This should now display the text correctly, based on the numeric value in the field named "A1". If your field has a different name, then you need to change the second line. 

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
New Here ,
Jun 05, 2021 Jun 05, 2021

Copy link to clipboard

Copied

LATEST

Thank you so so much, it works!

 

Really appeciate all your help. 

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