Can we use onchange script in onload client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 03:28 AM
Hi,
Can we use onchange script in onload client script.
I want to know about it and if answers is yes, please provide me one use case for it.
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 03:35 AM
No, and I don't really see a use case for it either. If you need to act on a change on the form you do a on-change client script 🙂
Best regards,
Sebastian Laursen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 03:47 AM - edited 01-09-2023 03:50 AM
Yes, you can use an onChange script in an onLoad client script. Here is an example:
onLoad client script:
function onLoad() { // other code here...
// set up onChange script for a field
g_form.addOnChange('field_name', function()
{ // onChange code here... }); }
This will set up an onChange script for the field 'field_name' that will run whenever the value of that field is changed.
Note: the onLoad client script will run when the form is first loaded, and the onChange script will run whenever the specified field is changed. If you want the onChange script to run when the form is first loaded, you can manually trigger the onChange event by using the following code:
g_form.fireOnChange('field_name');
This will cause the onChange script to run as soon as the form is loaded, in addition to running whenever the value of the field is changed.
But all said, as highlighted in the other response, the use case for such an ask is rare.
Kindly mark the response as Correct or Helpful.
Cheers,
Anish