Evolv Forms - On Load Code Workaroud

/* **************************************************************************** Evolv won't let us add javascript functions to a form's [After Load Code] field. The following is a WORKAROUND for this limitation. + The anonymous function uses a variable to trigger the [OnChange] event on the form. + The additional line of code removes the anonymous function from the form's XML in order to avoid an XSLT error. + The anonymous function's curly braces are doubled on purpose to avoid an XSLT error. How to use: - Create a variable named [on_load_code] of type {Boolean} - Paste the following code on the [On Load Script] field of the [on_load_code] variable - Add the code you want executed to the [On Change Script] field of the [on_load_code] variable **************************************************************************** */ window.setTimeout(function() {{ var cfs_code = getFormElementDOM('on_load_code'); if (document.nameProp.split(' ')[0] == 'ADD') {{ setFormElement('on_load_code', 1); cfs_code.focus(); cfs_code.blur(); }} getFormElementDOM('caption_on_load_code').style.display = 'none'; cfs_code.style.display = 'none'; }}, 50); /* ---------------------------------------------------------------------------- Prepend the following line to the [On Change Script] code. ---------------------------------------------------------------------------- */ getNodeFromXML(formXML, 'on_load_code').setAttribute('onload_event', ''); /* **************************************************************************** Alternative code for the 1st Form using the [On Click] event ---------------------------------------------------------------------------- */ window.setTimeout(function() {{ getFormElementDOM('on_load_code').click(); }}, 50); /* ---------------------------------------------------------------------------- Prepend the following line to the [On Change Script] code. ---------------------------------------------------------------------------- */ getFormElementDOM('on_load_code').style.display = 'none'; getFormElementDOM('caption_on_load_code').style.display = 'none';
Evolv won't let us add javascript functions to a form's [After Load Code] field. The following is a WORKAROUND for this limitation.
+ The anonymous function uses a variable to trigger the [OnChange] event on the form.
+ The additional line of code removes the anonymous function from the form's XML in order to avoid an XSLT error.
+ The anonymous function's curly braces are doubled on purpose to avoid an XSLT error.

How to use:
- Create a variable named [on_load_code] of type {Boolean}
- Paste the following code on the [On Load Script] field of the [on_load_code] variable
- Add the code you want executed to the [On Change Script] field of the [on_load_code] variable

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.