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

If else if statement error in PDF form

Community Beginner ,
Jul 13, 2018 Jul 13, 2018

I am working on a form for a bar contract for use at a local 503-C Social Hall which is rented out for fundraising to support the group.  The form contains five radio buttons to select the type of bar service package desired, and I am trying to have the selected package display on the billing page of the contract.   The following Javascript code generates this error:  "SyntaxError: Missing ; before statement 17: at line 18".  Any help deeply appreciated.

// This JavaScript Displays the chosen Bar Package from
// Page 1 of the Bar Contract by first retrieving the results
// of the Radio Button Selection on that page
var Package = this.getField("Bar Service").value;

// Then determine the Package price per person

if (Package == "None") {
    event.valu = "No Beverage Services Requested, No Charge."
} else if (Package == "Non-alcohol") {
    event.valu = "Non-Alcoholic Package Requested, $2.00 per person, per hour."
} else if (Package == "Beer") {
    event.valu = "Beer, Wine & Soda Package Requested, $4.00 per person, per hour."
} else if (Package == "Open") {
    event.valu = "Open Bar Package Requested, $7.00 per person, per hour."
} else (Package == "Cash") {
    event.valu = "Cash Bar Package Requested, $15.00 per Bartender, per hour, per 60 guests."
}

TOPICS
Acrobat SDK and JavaScript
523
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

correct answers 1 Correct answer

Community Beginner , Jul 13, 2018 Jul 13, 2018

Thank you for the assistance, I figured it out!  The following code works:

// This JavaScript Displays the chosen Bar Package from
// Page 1 of the Bar Contract by first retrieving the results
// of the Radio Button Selection on that page
var Package = this.getField("Bar Service").value;

// Then determine the Package price per person

if (Package == "None") {
    event.value = "No Beverage Services Requested, No Charge."
} else if (Package == "Non-alcohol") {
    event.value = "Non-Alcoholic Package Reque

...
Translate
Community Expert ,
Jul 13, 2018 Jul 13, 2018

1. It's event.value, not event.valu...

2. In the last clause you forget to add if before the else...

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 Beginner ,
Jul 13, 2018 Jul 13, 2018

Thank you for the rapid response.  I had already noticed and corrected the event.valu in the last line.  I tried your suggestion, and changed the last clause to read:

} if else (Package == "Cash") {

    event.value = "Cash Bar Package Requested, $15.00 per Bartender, per hour, per 60 guests."

}

and received the following error: "SyntaxError: missing ( before condition 17: at line 18"

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 Beginner ,
Jul 13, 2018 Jul 13, 2018

Thank you for the assistance, I figured it out!  The following code works:

// This JavaScript Displays the chosen Bar Package from
// Page 1 of the Bar Contract by first retrieving the results
// of the Radio Button Selection on that page
var Package = this.getField("Bar Service").value;

// Then determine the Package price per person

if (Package == "None") {
    event.value = "No Beverage Services Requested, No Charge."
} else if (Package == "Non-alcohol") {
    event.value = "Non-Alcoholic Package Requested, $2.00 per person, per hour."
} else if (Package == "Beer") {
    event.value = "Beer, Wine & Soda Package Requested, $4.00 per person, per hour."
} else if (Package == "Open") {
    event.value = "Open Bar Package Requested, $7.00 per person, per hour."
} else if (Package == "Cash") {
    event.value = "Cash Bar Package Requested, $15.00 per Bartender, per hour, per 60 guests."
}

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 13, 2018 Jul 13, 2018
LATEST

Sorry, I meant to write that you forget to add if ​after​ the else...

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