Copy link to clipboard
Copied
Hello, my question is how to check one string in one field for example:
if in fill_20 the string is "Sofia" or SOFIA or sOfia or all combinations with lowercase letters and uppercase letters and so..
If fill_20 is with content=Sofia and all combination with lowercase and uppercase letters then in fill_30 write value 100 if the string is different than Sofia then in fill_30 write 80?
Copy link to clipboard
Copied
The first two conditions will verify if the text is EXACTLY "Š”Š¾ŃŠøŃ" (irrelevant of upper/lower-case letters). The third will will check if it is anywhere within the string (also case-insensitive). So if you want to allow for other characters (like a space or other text) then use only the third if-statement.
Copy link to clipboard
Copied
In Adobe Acrobat DC you can use:
if ( testString.trim().toUpperCase() == "Š”ŠŠ¤ŠŠÆ")
Copy link to clipboard
Copied
Only this IF?
if ( testString.match(/ŃŠ¾ŃŠøŃ/i) != null )
????
Copy link to clipboard
Copied
Yeah this is enought for me!!
Now really work.
Thanks!
var testString = this.getField("fill_6").valueAsString;
if ( testString.match(/ŃŠ¾ŃŠøŃ/i) != null )
{
event.value = 100;
}
else
{
event.value = 80;
}
Copy link to clipboard
Copied
Hi tanerz18448860ā,
perhaps this is also a good way for all Acrobat versions
var testString = this.getField("fill_6").valueAsString;
if ( testString.match(/\s?ŃŠ¾ŃŠøŃ\s?/i) != null ) {
event.value = 100;
} else {
event.value = 80;
}
If so, have fun
Copy link to clipboard
Copied
I need help and today.
Now need to check strings with country if in field 1 the country is USA then in field 2 write 50, in field 3 write 80.
If the country in field 1 is Brazil then in field 2 write 40, in field 3 write 70.
If the country in field 1 is Spain then in field 2 write 35 in field 3 write 65.
And so and so.
How can I modify this to work with many checks and if's functions?
var testString = this.getField("fill_6").valueAsString;
if ( testString.match(/ŃŠ¾ŃŠøŃ/i) != null )
{
event.value = 100;
}
else
{
event.value = 80;
}
Copy link to clipboard
Copied
I successfully do it with to much IF'S.
But how can I do it with masives?
I do it with this codes and it's work..
var testString = this.getField("Dropdown7").valueAsString;
if ( testString.match(/ŠÆŠæŠ¾Š½ŠøŃ/i) != null )
{
event.value = 5500;
}
if ( testString.match(/ŠŠ²ŃŃŃŠøŃ/i) != null )
{
event.value = 35;
}
if ( testString.match(/ŠŠ²ŃŃŃŠ°Š»ŠøŃ/i) != null )
{
event.value = 35;
}
if ( testString.match(/ŠŠ·ŠµŃŠ±Š°Š¹Š“Š¶Š°Š½/i) != null )
{
event.value = 30;
}
I want to do it with masives:
I find this codes:
var c30 = ["ŠŠøŠ¼Š±Š°Š±Š²Šµ", "ŠŠ°ŠøŃ", "ŠŃŠøŠ¾ŠæŠøŃ"];
var c35 = ["ŠŠ°Š½ŠøŃ", "ŠŃŃŃŠøŃ", ŠŠµŃŠ¼Š°Š½ŠøŃ];
var x = "ŠŠøŠ¼Š±Š°Š±Š²Šµ";
var rez=0;
if(c30.indexOf(x)>=0){
rez = 30;
}
if(c35.indexOf(x)>=0){
rez = 35;
}
But ho can I implement it in java script in pdf forms?
Copy link to clipboard
Copied
I tried this but it doesn't work:
var c30 = ["ŠŠøŠ¼Š±Š°Š±Š²Šµ", "ŠŠ°ŠøŃ", "ŠŃŠøŠ¾ŠæŠøŃ"];
var c35 = ["ŠŠ°Š½ŠøŃ", "ŠŃŃŃŠøŃ", ŠŠµŃŠ¼Š°Š½ŠøŃ];
var x = "ŠŠøŠ¼Š±Š°Š±Š²Šµ";
var rez=0;
if(c30.indexOf(x)>=0){
rez = 30;
{
event.value= 30;
}
}
if(c35.indexOf(x)>=0){
rez = 35;
{
event.value=35;
}
}
Copy link to clipboard
Copied
It should work, but this will only be for exact matches, ie it won't work if you add a space after the string.
If you want further help you really have to start providing more exact descriptions of the issues you're having. "It doesn't work" is meaningless to us.
Copy link to clipboard
Copied
Why are you using the "rez" variable if you're applying the value to event.value directly? Get rid of rez and do it directly.
Also, you need to carefully look at the curly brackets in your code and make sure that they are set up correctly.
Copy link to clipboard
Copied
Okay, can you correct my code?
Copy link to clipboard
Copied
Try this:
var c30 = ["ŠŠøŠ¼Š±Š°Š±Š²Šµ", "ŠŠ°ŠøŃ", "ŠŃŠøŠ¾ŠæŠøŃ"];
var c35 = ["ŠŠ°Š½ŠøŃ", "ŠŃŃŃŠøŃ", "ŠŠµŃŠ¼Š°Š½ŠøŃ"];
var x = "ŠŠøŠ¼Š±Š°Š±Š²Šµ";
var rez = 0;
if (c30.indexOf(x)>=0){
rez = 30;
} else if (c35.indexOf(x)>=0) {
rez = 35;
}
event.value = rez;
Copy link to clipboard
Copied
This code solve my problem:
var testString = this.getField("Dropdown7").valueAsString;
var c30 = ["ŠŠøŠ¼Š±Š°Š±Š²Šµ", "ŠŠ°ŠøŃ", "ŠŃŠøŠ¾ŠæŠøŃ"];
var c35 = ["ŠŠ°Š½ŠøŃ", "ŠŃŃŃŠøŃ", ŠŠµŃŠ¼Š°Š½ŠøŃ];
if(c30.indexOf(testString)>=0){
event.value=30;
}
if(c35.indexOf(testString)>=0){
event.value=35;
}
Copy link to clipboard
Copied
This is not a good solution. If the text in question is not in either of the arrays then the value of the field will just stay as it was before...
Copy link to clipboard
Copied
No, it's work, user select the country from dropdown field where I define the country names.
var testString = this.getField("Dropdown7").valueAsString;
var c30 = ["ŠŠøŠ¼Š±Š°Š±Š²Šµ", "ŠŠ°ŠøŃ", "ŠŃŠøŠ¾ŠæŠøŃ", "ŠŠ·ŠµŃŠ±Š°Š¹Š“Š¶Š°Š½","ŠŠ»Š±Š°Š½ŠøŃ","ŠŃŠ¼ŠµŠ½ŠøŃ", "ŠŃŠ³Š°Š½ŠøŃŃŠ°Š½",
"ŠŠ°Š½Š³Š»Š°Š“ŠµŃ", "ŠŠ°Ń ŃŠµŠ¹Š½", "ŠŠµŠ»Š¾ŃŃŃŠøŃ", "ŠŠµŠ»ŠøŠŗŠ¾Š±ŃŠøŃŠ°Š½ŠøŃ", "ŠŠøŠµŃŠ½Š°Š¼", "ŠŠ°Š½Š°","ŠŃŃŠ·ŠøŃ", "ŠŃŃŠ³Šø ŃŃŃŠ°Š½Šø",
"ŠŠ³ŠøŠæŠµŃ", "ŠŃŃŠ¾Š½ŠøŃ","ŠŠ½Š“ŠøŃ", "ŠŠ½Š“Š¾Š½ŠµŠ·ŠøŃ","ŠŃŠ°Šŗ", "ŠŃŠ°Š½", "ŠŠµŠ¼ŠµŠ½", "ŠŠ¾ŃŠ“Š°Š½ŠøŃ", "ŠŠ°Š·Š°Ń ŃŃŠ°Š½", "ŠŠµŠ½ŠøŃ",
"ŠŠøŃŠ°Š¹", "ŠŠŠŠ ", "ŠŠ¾Š»ŃŠ¼Š±ŠøŃ", "ŠŠ¾ŃŠµŃ", "ŠŠ¾Ń Š“'ŠŠ²Š¾Š°Ń", "ŠŠøŠ±ŠøŃ", "ŠŠøŠ²Š°Š½", "ŠŠ°Š»Š°Š¹Š·ŠøŃ", "ŠŠ°Š»Šø",
"ŠŠ°ŃŠ¾ŠŗŠ¾", "ŠŠµŠŗŃŠøŠŗŠ¾", "ŠŠ¾Š·Š°Š¼Š±ŠøŠŗ", "ŠŠ¾Š»Š“Š¾Š²Š°", "ŠŠ¾Š½Š³Š¾Š»ŠøŃ", "ŠŠøŠ³ŠµŃŠøŃ", "ŠŠøŠŗŠ°ŃŠ°Š³ŃŠ°", "ŠŠ¾Š²Š° ŠŠµŠ»Š°Š½Š“ŠøŃ",
"ŠŠ±ŠµŠ“ŠøŠ½ŠµŠ½Šø Š°ŃŠ°Š±ŃŠŗŠø ŠµŠ¼ŠøŃŃŃŠ²Š°", "ŠŠ°ŠŗŠøŃŃŠ°Š½", "ŠŠµŃŃ", "Š”Š°ŃŠ“ŠøŃŃŠŗŠ° ŠŃŠ°Š±ŠøŃ", "Š”ŠøŠ½Š³Š°ŠæŃŃ", "Š”ŠøŃŠøŃ",
"Š¢Š°Š“Š¶ŠøŠŗŠøŃŃŠ°Š½", "Š¢ŃŠ½ŠøŃ", "Š¢ŃŃŠŗŠ¼ŠµŠ½ŠøŃŃŠ°Š½", "Š¢ŃŃŃŠøŃ", "Š£Š·Š±ŠµŠŗŠøŃŃŠ°Š½", "Š£ŠŗŃŠ°Š¹Š½Š°", "Š§ŠøŠ»Šø", "Š®ŠŠ "];
var c35 = ["ŠŠ°Š½ŠøŃ", "ŠŃŃŃŠøŃ","ŠŠµŃŠ¼Š°Š½ŠøŃ","ŠŠ¾Š»ŃŠ°","ŠŠ²ŃŃŃŠ°Š»ŠøŃ / Australia", "ŠŠ»Š¶ŠøŃ", "ŠŠ½Š³Š¾Š»Š°",
"ŠŃŠ¶ŠµŠ½ŃŠøŠ½Š° / Argentina", "ŠŠµŠ»Š³ŠøŃ", "ŠŠ¾ŃŠ½Š°", "ŠŃŠ°Š·ŠøŠ»ŠøŃ","ŠŠøŠ±ŃŠ°Š»ŃŠ°Ń","ŠŠ·ŃŠ°ŠµŠ»", "ŠŃŠ»Š°Š½Š“ŠøŃ",
"ŠŃŠ»Š°Š½Š“ŠøŃ", "ŠŃŠæŠ°Š½ŠøŃ", "ŠŃŠ°Š»ŠøŃ", "ŠŠ°Š½Š°Š“Š°", "ŠŃŠæŃŃ", "ŠŃŠ±Š°", "ŠŃŠ²ŠµŠ¹Ń", "ŠŠ°ŃŠ²ŠøŃ", "ŠŠøŃŠ²Š°",
"ŠŠøŃ ŃŠµŠ½ŃŠ°Š¹Š½", "ŠŃŠŗŃŠµŠ¼Š±ŃŃŠ³", "ŠŠ°ŠŗŠµŠ“Š¾Š½ŠøŃ", "ŠŠ°Š»ŃŠ°", "ŠŠ¾Š½Š°ŠŗŠ¾","ŠŠ¾ŃŠ²ŠµŠ³ŠøŃ", "ŠŠ¾ŃŃŃŠ³Š°Š»ŠøŃ",
"Š ŃŠ¼ŃŠ½ŠøŃ", "Š ŃŃŠøŃ", "Š”Š°Š½ ŠŠ°ŃŠøŠ½Š¾", "Š”ŠŠ©", "Š”Š»Š¾Š²Š°ŠŗŠøŃ", "Š”Š»Š¾Š²ŠµŠ½ŠøŃ", "Š£Š½Š³Š°ŃŠøŃ", "Š¤ŠøŠ½Š»Š°Š½Š“ŠøŃ",
"Š¤ŃŠ°Š½ŃŠøŃ", "Š„Š¾Š»Š°Š½Š“ŠøŃ", "ŠØŠ²ŠµŃŠøŃ", "Š§ŠµŃ ŠøŃ", "Š®Š³Š¾ŃŠ»Š°Š²ŠøŃ" ];
var c60 = ["ŠØŠ²ŠµŠ¹ŃŠ°ŃŠøŃ"];
var c5500 = ["ŠÆŠæŠ¾Š½ŠøŃ"];
if(c30.indexOf(testString)>=0)
{
event.value=30;
}
if(c35.indexOf(testString)>=0)
{
event.value=35;
}
if(c60.indexOf(testString)>=0)
{
event.value=60;
}
if(c5500.indexOf(testString)>=0)
{
event.value=5500
}