Copy link to clipboard
Copied
I need a script to change the textbox value direction to right to left or left to right as the language in the dropdown list i used the script below and the alignment worked useful but the direction is not working:
// Get the language from a dropdown or text field
var language = this.getField("lang").value;
// Get the text field
var textField = this.getField("Textbox");
// Set the direction based on the language
if (language === "ARABIC") {
textField.alignment = "right";
textField.direction = "rtl"; // right-to-left
} else if (language === "ENGLISH") {
textField.alignment = "left";
textField.direction = "ltr"; // left-to-right
}
Copy link to clipboard
Copied
Form text fields doesn't have a property direction.
Copy link to clipboard
Copied
They do, actually, but it can't be set using a script, only manually.
If your application has the RTL options enabled (under Preferences - Language) then you can set a field's direction as Right-to-Left or Left-to-Right, via its Properties, under the Appearance tab:
Copy link to clipboard
Copied
I make this form for other users and I will lock any edits in the form so I need it in javascript
Copy link to clipboard
Copied
I don't understand how these two things are related, but as I said, it can't be done in JS, so you need to do it manually.
Copy link to clipboard
Copied
Ah, I see what you mean now, but it can't be done. As Bernd suggested, create two fields with the correct Direction option pre-selected and make them visible/hidden based on the user's selection.
Copy link to clipboard
Copied
Do you mean if I have 100 Fileds I should duplicate them in the form and the code
Copy link to clipboard
Copied
Copy link to clipboard
Copied
> Do you mean if I have 100 Fileds I should duplicate them in the form and the code
Yes.
> the script is working useful with HTML why is it not working in the PDF form
Because HTML and PDF are not the same thing.
Copy link to clipboard
Copied
textbox option includes directions and I can change it manually but I need it in javascript
Copy link to clipboard
Copied
Use two fields with different directions and show/hide the fields in the script.
Copy link to clipboard
Copied
Not working