Buy Now
Sign in

Javascript triggered by checkbox

squiffed , March 16 2018
Am trying to do a pretty simple Javascript that worked fine in CF4. I have a checkbox that when clicked will copy info from text1 to text2.
In CF4 I had the Javascript in the 'On Load/Load JS' and it was set up as 'domready' event for the window. So it looked like this:
window.addEvent('domready', function() {
$('id_cb1').addEvent('click', function(){
.... do the copy stuff ....
When the checkbox was clicked it copied or cleared some fields on my form.
In CF6 I'm doing something wrong.
I put my function into a Javascript field and checked the 'add inside domready' and gave it a name.
function copy_tc(){
... do the copy stuff....
and then in the checkbox event area, I selected 'click' put the name of the function in the Element Identifier (see pic).
Am probably missing something obvious or have something syntactically wrong, but have iterated thru quite a few options, searched forums and perused manual before posting this.
Hi squiffed,
The function name in the "Element identifier" should NOT have the brackets!
Also the "JavaScript" element should not have the "add inside domready" enabled.
Best regards
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
Thank you. I thought I'd iterated thru all the various ways to do it, but evidently I didn't try that combination.