Skip Navigation

[Resolved] Auto submit form when checkbox is checked

This support ticket is created 4 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by jorgeB-3 4 years, 12 months ago.

Assisted by: Shane.

Author
Posts
#1632195

Hi,

I have a form to edit post categories. Posts can have three categories and the form shows three checkboxes with the current post categories checked.

See hidden link

Now, I need to submit the form when one of the checkboxes is checked/unchecked.

Submit button is removed.

Is it possible?

Thanks!

#1632393

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jorge,

Thank you for getting in touch.

This is possible but you will have to use custom coding to get this to work.

What you will need to do is adapt the code in the link below to your form in order for it to submit the form.
https://stackoverflow.com/questions/18135420/jquery-javascript-submit-form-when-checkbox-is-clicked

This code will go to the JS section

Please let me know if this helps.
Thanks,
Shane

#1632425

Hi Shane,

Thank you for your reply.

This is the code that I have in JS section:

$(".wpt-form-item-checkbox").change(function() {
$(".cred-form").submit();
});

But it doesn't work.

Regards.

#1632451

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jorge,

Try using this code here

jQuery("input[type='checkbox']").change(function() {
jQuery(".cred-form").submit();
});
#1632455

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

I've modified the code some more to submit only the selected form.

jQuery("input[type='checkbox']").change(function() {
jQuery(this).submit();
});
#1632703

Good job, Shane!

It works fine.

Thank you very much.