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

Conditional fields if one field is empty, the others to be empty also, if not empty, for it to have a percentage or grade.

New Here ,
Mar 11, 2019 Mar 11, 2019

I want the second line to be empty if the marks (like it is now) to be empty. I have this in the % field under progress at the moment (where the 17 currrently is)

((DataTest +StudentInvestigation)/30)*100

and in the result section I have this.

var perc = this.getField("Percentage2").valueAsString;

if (perc=="") event.value = "";

else {

    perc = Number(perc);

    if (perc<25) event.value = "E";

    else if (perc<45) event.value = "D";

    else if (perc<65) event.value = "C";

    else if (perc<85) event.value = "B";

    else event.value = "A";

}

I'm not sure how to add the "if ___ field is empty" part to it.

TOPICS
PDF forms
1.2K
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 ,
Mar 12, 2019 Mar 12, 2019

Do you mean for the first calculation? You can use something like this:

var s1 = this.getField("DataTest").valueAsString;

var s2 = this.getField("StudentInvestigation").valueAsString;

if (s1=="" || s2=="") event.value = "";

else event.value = ((Number(s1)+Number(s2))/30)*100;

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 ,
Mar 12, 2019 Mar 12, 2019

Yes thank you,

and the Grade field as well.

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 ,
Mar 12, 2019 Mar 12, 2019

The script above already does that.

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 ,
Mar 12, 2019 Mar 12, 2019

Yes it does for the percentage, but in the result field it still comes up with an "E" even though the percentage is nothing.

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 ,
Mar 12, 2019 Mar 12, 2019

Oh never mind, its because I did the input wrong for the last one. Thank you again.

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 ,
Mar 12, 2019 Mar 12, 2019

Hi,

Sorry now, when I change the numbers it doesn't update the grade in the result section.

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 ,
Mar 12, 2019 Mar 12, 2019
LATEST

Check the JS Console (Ctrl+J) for error messages.

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