Power - 1 year ago 74

Javascript Question

Using java script of PDF forms, how to change the digits style (from English to Arabic numbers) of a script-added-field?

Answer Source

digit mapping function for each field:

```
var eng_digits = ["0","1","2","3","4","5","6","7","8","9","."]
var arb_digits = ["٠","١","٢","٣","٤","٥","٦","٧","٨","٩",","]
function change_digits(num,form){
var string = "" + num
var digits = string.split("")
for (i=0; i<digits.length; i++){
if(form == "arb"){
digits[i] = arb_digits[eng_digits.indexOf(digits[i])];
}else if (form == "eng"){
digits[i] = eng_digits[arb_digits.indexOf(digits[i])];
}
}
return digits.join("");
}
this.getField("myField").value = change_digits(this.getField("myField").value, "arb")
```