Skip to main content
Participant
February 23, 2023
Question

choosing from a list

  • February 23, 2023
  • 2 replies
  • 1378 views

Hello , I have a PDF file as form and it has a list in  it.

what i want is when the user choose an item from the list, shows some text field and hide another.

and i wrote this code but what it does escap all the IF statment and executes the ELSE statment only whatever the user chooses from the list.

 

if (event.value == "Option1" {
    this.getField("Show_1").display = display.visible;    
    this.getField("Show_2").display = display.hidden;
}
else if (event.value == "Option3") {
    this.getField("Show_1").display = display.hidden;    
    this.getField("Show_2").display = display.visible;
}
else {
    this.getField("Show_1").display = display.hidden;    
    this.getField("Show_2").display = display.hidden;
}

 

so what is wrong with my code.

NOTE: Inside the parentheses is Arabic text which is the list items (option1) and the names of the fields (show_1)  that I want to hide or show.

This topic has been closed for replies.

2 replies

JR Boulay
Community Expert
Community Expert
February 23, 2023

You can use this free Text to Unicode converter.

Copy-paste this URL in Google Translate if you can't read French: https://www.abracadabrapdf.net/utilitaires/utilitaires-pdf/texte-vers-unicode/

Acrobate du PDF, InDesigner et Photoshopographe
Participant
February 24, 2023

thanks alot dear JR Boulay for your help I converted all my text by using the free Text to Unicode converter that you gave

try67
Community Expert
Community Expert
February 23, 2023

The code seems fine. The issue might be with the Arabic text, though. Did you make sure your code is encoded correctly for it? Might be a good idea to use Unicode characters, instead of hard-coding the Arabic characters themselves into your code.

Participant
February 24, 2023

thank you dear try67, i used th Unicode characters but doesn't work.

 

also go to the ELSE statment.

//ro5sat taswet wade
if (event.value == "\u0631\u062E\u0635\u0629\u0020\u062A\u0633\u0648\u064A\u0629\u0020\u0648\u0636\u0639") {
//kroky01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0643\u0631\u0648\u0643\u064A\u0627\u062A\u0031").display = display.visible;
//kroky02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0643\u0631\u0648\u0643\u064A\u0627\u062A\u0032").display = display.visible;
//tasmem01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062A\u0635\u0645\u064A\u0645\u0031").display = display.hidden;
//tasmem02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062A\u0635\u0645\u064A\u0645\u0032").display = display.hidden;
//drast01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062F\u0631\u0627\u0633\u0627\u062A\u002E\u0030").display = display.hidden;
//drast02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062F\u0631\u0627\u0633\u0627\u062A\u002E\u0031").display = display.hidden;
//eshraf01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0627\u0634\u0631\u0627\u0641\u0031").display = display.hidden;
//eshraf02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0627\u0634\u0631\u0627\u0641\u0032\u002E\u0030").display = display.hidden;
}
else if (event.value == "\u0631\u062E\u0635\u0629\u0020\u0647\u062F\u0645") {
//kroky01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0643\u0631\u0648\u0643\u064A\u0627\u062A\u0031").display = display.hidden;
//kroky02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0643\u0631\u0648\u0643\u064A\u0627\u062A\u0032").display = display.hidden;
//tasmem01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062A\u0635\u0645\u064A\u0645\u0031").display = display.hidden;
//tasmem02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062A\u0635\u0645\u064A\u0645\u0032").display = display.hidden;
//drast01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062F\u0631\u0627\u0633\u0627\u062A\u002E\u0030").display = display.hidden;
//drast02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062F\u0631\u0627\u0633\u0627\u062A\u002E\u0031").display = display.hidden;
//eshraf01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0627\u0634\u0631\u0627\u0641\u0031").display = display.visible;
//eshraf02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0627\u0634\u0631\u0627\u0641\u0032\u002E\u0030").display = display.visible;
}
else {
//kroky01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0643\u0631\u0648\u0643\u064A\u0627\u062A\u0031").display = display.hidden;
//kroky02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0643\u0631\u0648\u0643\u064A\u0627\u062A\u0032").display = display.hidden;
//tasmem01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062A\u0635\u0645\u064A\u0645\u0031").display = display.hidden;
//tasmem02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062A\u0635\u0645\u064A\u0645\u0032").display = display.hidden;
//drast01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062F\u0631\u0627\u0633\u0627\u062A\u002E\u0030").display = display.visible;
//drast02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u062F\u0631\u0627\u0633\u0627\u062A\u002E\u0031").display = display.visible;
//eshraf01
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0627\u0634\u0631\u0627\u0641\u0031").display = display.hidden;
//eshraf02    
    this.getField("\u0627\u062A\u0641\u0627\u0642\u064A\u0629\u0020\u0627\u0634\u0631\u0627\u0641\u0032\u002E\u0030").display = display.hidden;
}

 

try67
Community Expert
Community Expert
February 24, 2023

Can you share the file with us?