Using onclick and onfocusout in form fields

Hi,

I’m trying to make a product form that calculates the price depending upon what options there are selected in the form. I got the JS working but need to add onclick and onfocusout triggers to form elements. Both are reserved attributes. Is there any way of doing this without having to put the form elements into an html embed?

1 Like

Use onclick and onfocusout vanilla js (or Jquery) events (using the addEventListener() method).

This is ± the outline (select element X and run Function Y on Event):

Jquery option:
https://api.jquery.com/focusout/

Add read-only link for specific example.

1 Like