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
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more