Hi,
I have a form where a javascript function executes when a field is changed: so, when a user enters a value into Field 1 or Field2, a js function is called as an Event in the Form, performs a calculation and places the result in Field 3, using the On Change trigger. Works well.
However when I populate the form from a database table or external file, the fields are filled but the js function is not run unless the user changes one of the input fields after loading.
I did try the Not empty trigger but this did not work either.
Is there a way that I can get CF6 to execute the js function when the fields are populated from the database? Preferably a way to run it when triggered by the data being loaded into the field.
Thanks
Tim
I have a form where a javascript function executes when a field is changed: so, when a user enters a value into Field 1 or Field2, a js function is called as an Event in the Form, performs a calculation and places the result in Field 3, using the On Change trigger. Works well.
However when I populate the form from a database table or external file, the fields are filled but the js function is not run unless the user changes one of the input fields after loading.
I did try the Not empty trigger but this did not work either.
Is there a way that I can get CF6 to execute the js function when the fields are populated from the database? Preferably a way to run it when triggered by the data being loaded into the field.
Thanks
Tim
Hi Tim,
You probably need to run your function when the page loads. See this StackOverFlow page for several ways to do this.
Bob
You probably need to run your function when the page loads. See this StackOverFlow page for several ways to do this.
Bob
Thanks Bob,
It looks like a good way to go, but I am not certain how that translates into a typical CF6 form.
If I wanted to use one of the solutions here, say
Cheers
Tim
It looks like a good way to go, but I am not certain how that translates into a typical CF6 form.
If I wanted to use one of the solutions here, say
window.onload = function ...How would I do it? In a custom code after the Display Form?
Cheers
Tim
There's custom JS code blocks in CFv6, and there's a big giant "on page load" checkbox.
HI!
I had the same problem on a CF7 form and the option "on page load" / "add inside domready event" don't work.
So i've put an img at the end of the page with a transparent 1x1 pixel image that call the function:
<img src="images/pxl.png" alt="" onload="myFunction()" />
and it's work.
p.
I had the same problem on a CF7 form and the option "on page load" / "add inside domready event" don't work.
So i've put an img at the end of the page with a transparent 1x1 pixel image that call the function:
<img src="images/pxl.png" alt="" onload="myFunction()" />
and it's work.
p.
You need to login to be able to post a reply.