Well you can do this task as you are expecting…you just have to create a form element which you are expecting on with a CFormbuilder like checkbox. and call a javascript function on the checkbox.
Define a javascript as you want like on the same view file or register it in a view file.
Now to create a Dynamic Form field with javascript.You can create html field on the form.
To check the format of form element check the HTML source of form and create a html element which you want to create on form.