- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks in advance for your help!
I have 2 fields one takes a percentage of the base pay for an increase and the other takes a dollar amount of the increase.
We want the user to be able to fill one of the fields in and the onChange script will make the calculation to fill in the other.
The problem that I'm having is that if both scripts are Active, they trigger each other and then I get the following error:
onChange script error: SyntaxError: Invalid regular expression: /(^|[\x20\t\r\n\f])form-field([\x20\t\r\n\f]|$)/: Stack overflow function () { [native code] }
The information I've been able to find indicates that I'm running into Recursion. The suggested solution was to add newValue === oldValue as follows:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Post both scripts for more insight, but it seems like you should do something like:
if (g_form.getValue('the other field') != the_value_to_be_set) {
g_form.setValue('the other field', the_value_to_be_set;
}
In this way the 'other field' will not be updated if the value is already what you're about to set it to, which if done in both scripts would head-off the recursion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Post both scripts for more insight, but it seems like you should do something like:
if (g_form.getValue('the other field') != the_value_to_be_set) {
g_form.setValue('the other field', the_value_to_be_set;
}
In this way the 'other field' will not be updated if the value is already what you're about to set it to, which if done in both scripts would head-off the recursion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks Brad!
Worked like a charm!
Now I'm kicking myself for not thinking of it 😁
Dave
