Forums

Javascript triggered by checkbox

squiffed 16 Mar, 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.


Max_admin 20 Mar, 2018
Answer
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
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
squiffed 20 Mar, 2018
1 Likes
Thank you. I thought I'd iterated thru all the various ways to do it, but evidently I didn't try that combination.
This topic is locked and no more replies can be posted.