Copy link to clipboard
Copied
I have field1 and field 2, on field 1 I have app.alert to limit me from entering specific value from field 2 even though field 1
doesn't calculate that value when alert pop it
still change value in field2. What I need to do so when I get alert that field2 stay same and doesn't change it's current value?
1 Correct answer
Then modify my custom calculation script above for Field2 like this:
if (event.value <= 30) {
this.getField("Field1").value = event.value;
} else {
if (event.value > 30) { event.value = this.getField("Field1").value;
}
}
Don't change anything. Try it out first as instructed.
In the solution I am giving to you the app alert is not executed in Field1. If you have any calutlations or app.alert scripts in Field1 get rid of it. Or we will continue like the chicken or the egg story of what came fi
...Copy link to clipboard
Copied
Please share your code or your file.
Copy link to clipboard
Copied
I don't have code for field2.
in field1 is just simple calculation nothing more, app.alert comes from "field value is in range".
Just need help if alert pop, field2 also stay same, because now even though field1 doesn't change it's value if alert pop entered value in field2 stay in it.
Copy link to clipboard
Copied
Please give us the actual code you already have. Please copy and paste it. Also please post your idea for the new code, even if wrong. We hope to help you learn how to write your code, not to just write it all for you.
Copy link to clipboard
Copied
var a = this.getField("field1").value;
var b = this.getField("field2");
if( a == (don't know what to write here if value in field1 didn't change)){
b = (value need to stay same if field1 didn't change);
}
Copy link to clipboard
Copied
Still need help with this one.
Copy link to clipboard
Copied
Thank you for your more detailed reply. Please allow a few days to see if someone sees your message who wants to help. Especially as it is the weekend and still the middle of the night in US.
Copy link to clipboard
Copied
When you use following validation:
Acrobat will display a message when you enter a wrong value. In this case Acrobat doesn't use app.alert.
Copy link to clipboard
Copied
Here are two recent discussions that can help you figure out how to incorporate a similar script to cope with your struggle(s):
Copy link to clipboard
Copied
Sorry I don't see how those posts could help me?
Copy link to clipboard
Copied
You asked about a popup alert.
The the structure of the scripts in those two discussions is what I was trying to share with you as examples.
It shows how an alert is triggered based on a condition when a value changes in another field.
Isn't that what you're struggling with?
Copy link to clipboard
Copied
app.alert is not part of problem my problem is whats happening when alert pop.
il try to explain, in field1 I have default value of 30 and it's range is set from 0-30 so if i enter value larger then 30 I get alert and value is not writen then but it's still written in field2 where i'm entering that value,so what I need is if I enter in field2 value of 50 field1 will give alert and won't write value if that happen field2 also shouldn't write value, so basicaly if alert for field1 pop field2 also doesn't change.
Copy link to clipboard
Copied
How does you change the value of field2?
Copy link to clipboard
Copied
I enter value in field2 with dialog box.
Copy link to clipboard
Copied
Why does you use a dialog box for this?
Copy link to clipboard
Copied
because I have other info in dialog box that user need to see before entering values to field2
Copy link to clipboard
Copied
When you don't want change the value in field2 then don't call the dialog box.
Copy link to clipboard
Copied
I don't wan't to change value in field2 only when field1 doesn't change it's value cuz of alert.pop.
Copy link to clipboard
Copied
I asked you to post your code, and it turns out there is all sorts of extra code with dialog boxes and everything. Please don't ask us to help while blindfolding us!!
Copy link to clipboard
Copied
Did any of you even read my OP? everything is explained there non of other codes or dialog boxes matter for my problem, either help me or don't ask me unnecessary questions.
Copy link to clipboard
Copied
Is all good bro.
It's just that people come here to the forums asking for complex stuff but they start with a very easy question....then they start adding more crap to the equation; in the end, having community memebers do the work for them that otherwise should be paid for.
We will help you. But that had to be clarified and get it out of the way.
The way you're phrasing your inquiry each time seems like it changes all the time. Some of us also struggle with language barriers.
But anyway, this is what I understood after re-reading this discussion a several times:
- You have to two text fields. One is named Field1 , the other Field2.
- Whatever a user inputs manually in Field1 will autopopulate Field2. However, user is restricted from enter any value that is greater than 30 in Field1.
- If the input value of Field1 is greater than 30, then an alert will trigger to notify the user that it can't greater than 30.
- What you need is that when this condition is met, where a value is greater than 30 in Field1, that Field2 remains with the value that was entered in Field1 by the user ( which was greater than 30) but reset or clear Field1 after the alert dialogue box is closed and not alter Field2.
Is this correct , please confirm so we're all tracking the same information.
You're issue is not that hard to resolve.
All you need is probably a conditional statement, and I would say that maybe a validation script which will get this done.
Copy link to clipboard
Copied
sry and thx for helping english isn't my first language so sorry if I don't express myself right.
I don't know how to explain it easier but Il try, field1 get it's value from field2 and field1 has app alert set for value range 0-30. if I enter 5 in field2 it will show in field1 and in field2(obviusly) but if I enter after that 50 in field2, field1 will pop alert and it's value will remain 5 but field2 value will now change to 50. what i need is if field1 stay at 5 field2 also should stay at 5 and not show 50.
EDIT: This is not valid code but it shows what would I like it to do,maybe it will be easier for you to understand.
var a = this.getField("Points").event;
if(a.event == app.alert){
this.getField("C2").value = ReturnValue;
}
Copy link to clipboard
Copied
Do it like this:
In Field2 use put this script in the "Validate" tab --->> "Run custom validation script" section
if (event.value > 30) {
app.alert("Invalid value. Please enter a value between 0-30", 0);
event.rc = true;
}
And then in the Calculate tab of Field2, use this script as custom calculation script:
if (event.value <= 30) {this.getField("Field1").value = event.value }
Copy link to clipboard
Copied
That's all you need really.
And I'm sure there's so many other ways to do it.
But this is what work for me on my end.
Copy link to clipboard
Copied
I forgot to add that you need to set your fields' custom format as Numbers.
Since Field 2 will control much of what happens, you also need to set a range from 0 to 30 in Field1 and lock it. This allows the script From Field2 to work as described in my reply above, but if the user wants to manually change the Field1 value manually it won't allow to enter anything that is greater than 30..
See slide:
Don't complicate yourself too much. Sometimes is better to use Acrobat's built-in features. In fact, I've seen experienced ACP's recommend this too.
If there's a result you can achieve without JavaScript then use it. This will keep work work somewhat more simplified and less prone to errors and testing.


-
- 1
- 2