Buy Now
Sign in

CF6 How to clear specific fields via reset button

xoles , May 20 2017, 19:35
xoles 18
May 20 2017, 19:35 #368404
Hi, in my form I use the events tab to add up values from several textfields into a "total sum" textfield. First save works just fine, but when trying to update that same form, if you change values from the fields it won't subtract and any other value you enter will sum to the previously loaded "total sum" value.

I thought that a reset button just for those fields (not for the entire form) would be a good solution, instead of coding a way to add or subtract depending on the new field value; but I can't figure out how to.

The reset-type button by itself won't clear any field, I think I'm missing a function or event. I created a button-type button and tried to javascript it to clear fields, but can't make it work. I don't know if the function js code goes before or after the button, or if I have to place something extra on the setup tab, or if it can be done with php.

Any suggestions on how to achieve this?
admin 29
May 20 2017, 22:10 #368406
Hi xoles,

The reset button resets the fields to their default values when the form was loaded, so if your fields had some values already then the reset button can't clear them, instead you can clear them with JS:


Best regards,
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
xoles 18
May 20 2017, 22:40 #368407
Thanks Max, I'm trying with no luck this js code before the input field:

 document.getElementById('reset').onclick= function() {

and a button with id 'reset' after the input field. All these on design tab; nothing extra on setup tab.
GreyHead 64
May 21 2017, 07:58 #368413
Hi xoles,

The JS code should be in a Load JavaScript action on the Setup tab - not in the Design tab.

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much