Actions in Mailocator - onSubmit
Dynamic change of the onSubmit event based on user behavior
What are Actions?
OnSubmit event and dynamic event change
onsubmitevent, most often by:
filling in the form (eg checking the subscription),
status of cookies or dataLayer.
In addition to the parameter of the function
mailocator.action.do (), the action can also be sent using the value of the attribute
mlctr-action, which you can change dynamically.
The content of the parameter of the function
mailocator.action.do ()cannot be changed dynamically, browsers may consider such an attempt as a violation of security rules.
Questionnaire with the possibility of subscribing to newsletters
INQUIRYmay also, if the user agrees, forward the email address to the Newsletter (ESP).
mailocator.action.do ()function parameter blank.
Fill in the attribute
Enter the desired default action in the attribute value.
<form onsubmit="return mailocator.action.do()" mlctr-action="subscribe:1|send">
After checking the checkbox - agree to subscribe - change the value of the attribute
If the checkbox is checked, we want to send an event to Mailocator to send a query and at the same time to subscribe -
If the user did not check the box, the form will be submitted by action
<input type="checkbox" value="1" onclick="this.checked ?
(document.querySelector('[mlctr-action]').setAttribute('mlctr-action','subscribe:1|send')) : (document.querySelector('[mlctr-action]').setAttribute('mlctr-action','send'))">