Hi all
Does anyone know if it is possible to check whether the value in a field has changed when the field is updated within a script? In other words, I need the OnChange event of a field to call a script when the field is set by a script, rather than by the user.
If this is not possible, is there an FPL equivalent of the externalsubmit() Java function, as the script could be attached to the OnValidate event.
Any help would be greatly appreciated
Cheers
Simon
Check for changes to field without user input
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 25
- Joined: Thu Aug 27, 2009 9:43 am
- Location: Hampshire County Council
- Contact:
-
- Ebase User
- Posts: 94
- Joined: Fri Sep 14, 2007 12:18 pm
- Location: The Netherlands
- Contact:
Re: Check for changes to field without user input
I am not sure that you can. The options I can think of:
- - use "callscript" in the script that changes the field to run the scripts that would normally be run on the field change.
- use a control field with the on-change scripts attached to the validate option to always check the field.
- use helper variables that store the value from the last test by the on-change script and use these in the after page event to see whether the on-change scripts need to be called again (using callscript).
0 x
-
- Ebase User
- Posts: 25
- Joined: Thu Aug 27, 2009 9:43 am
- Location: Hampshire County Council
- Contact:
Re: Check for changes to field without user input
Hi AJ, thanks for your reply.
which refreshes the page and forces the field to validate. This script can be called from the same script that changes the field value.
To prevent the form from refreshing indefinitely, we used a Boolean field to track whether a change has been detected. This is set to false when the onValidate event is triggered. The externalSubmit is then fired and when the page refreshes, the Boolean is set to true and the JavaScript field is set to blank again.
A bit of a hack, to be sure, but got there in the end!
Cheers man, take care
Simon
A good idea, but the problem I have is that the field is held in a global component. When the field is changed, it fetches a row from a database resource, which is mapped in the component. However, the field is changed by a script called from the form containing the component; if this script calls the global script that fetches the row, I will need to create and map fields within the form, rather than the component. Since I want this component to be generic and reusable, this would create duplication of effort.AJDulk wrote:
- - use "callscript" in the script that changes the field to run the scripts that would normally be run on the field change.
I tried this, but it seems the OnValidate event is only triggered when the user changes the value of the field, rather than a script. Back to square oneAJDulk wrote:
- - use a control field with the on-change scripts attached to the validate option to always check the field.
This is good, and similar to the solution we employed. We created a global script which uses JavaScript to call externalSubmit():AJDulk wrote:
- - use helper variables that store the value from the last test by the on-change script and use these in the after page event to see whether the on-change scripts need to be called again (using callscript).
Code: Select all
set GF_HCCGF_MSG__TXT_JAVASCRIPT = '<script>externalSubmit();</script>';
To prevent the form from refreshing indefinitely, we used a Boolean field to track whether a change has been detected. This is set to false when the onValidate event is triggered. The externalSubmit is then fired and when the page refreshes, the Boolean is set to true and the JavaScript field is set to blank again.
A bit of a hack, to be sure, but got there in the end!
Cheers man, take care
Simon
0 x
-
- Ebase User
- Posts: 94
- Joined: Fri Sep 14, 2007 12:18 pm
- Location: The Netherlands
- Contact:
Re: Check for changes to field without user input
AJDulk wrote:
- - use a control field with the on-change scripts attached to the validate option to always check the field.
True if you use the field you are checking itself, you need to create a 2nd field and change its type to "Control Field" (First checkbox in the Field Properties). That field then needs to be placed on the form and the scripts placed in the Validation box. If you have done this and it is not working then that is strange. Scripts in Validation on the Control Field should always fire according to the documentation. I have also used this succesfully in the past.Simon wrote:I tried this, but it seems the OnValidate event is only triggered when the user changes the value of the field, rather than a script. Back to square one
0 x
-
- Ebase User
- Posts: 25
- Joined: Thu Aug 27, 2009 9:43 am
- Location: Hampshire County Council
- Contact:
Who is online
Users browsing this forum: No registered users and 138 guests