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

field not showing the javascript result

Guest
Oct 18, 2016 Oct 18, 2016

What am I doing wrong; the field with  the following javascript is not showing the result?

var z = this.getField("total5c").value;

if  (z >= 0) {

event.value = getField("total6c").value / z;

} else {

event.value = 0;

}

TOPICS
Acrobat SDK and JavaScript
339
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 ,
Oct 18, 2016 Oct 18, 2016

Are you getting any errors on the JavaScript console (use Ctrl-J or Cmd-J to display it)? If not, are you sure you are using the script as a custom calculation script?

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
Guest
Oct 18, 2016 Oct 18, 2016

I'm using the Actions JavaScript. I opened the javaScript Debugger and it shows the following invalidseterror or unknown  not sure what the all means

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
Guest
Oct 18, 2016 Oct 18, 2016

JavaScript Debugger shows but I'm not sure what to to or look for? I based the script from examples. I'm totally new to javascript and only mangle to get copy and paste examples to get my fields to process the code. Using the Calculate works on the simplified field notation  but I want if statement. not sure what to do. The script is in the Actions  tab not Calculat tab.

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 ,
Oct 18, 2016 Oct 18, 2016

Is this for a button action? A button does not have an event.value property. If you want to calculate a field, you would use the field's calculation tab and then select the "custom calculation script" option. If this does not help, can you share your PDF file?

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
LEGEND ,
Oct 18, 2016 Oct 18, 2016

Also you really don't want to divide by z if z is zero. Consider what you want to show in this case.

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
LEGEND ,
Oct 18, 2016 Oct 18, 2016
LATEST

By the way if you get errors and don't understand them please copy and paste the entire script and entire console into the same message for people to take a look at. Don't summarize!

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