☀ Check out our new pay-what-you-want Webflow portfolio template — Exhibit
Guides
snippets
Submit Form From Radio Button

Submit Form From Radio Button

November 22, 2022

Let's imagine you have some kind of review system for your articles in which you allow users to submit the helpfulness of the article by clicking on star icons from 1 star to 5 stars.

When a user clicks one of the stars, you want a form to submit the review to whatever back-end you're using.

This is how you can do that with a few lines of jQuery:

$(document).ready(function () {
  $('[name="stars"]').click(function () {
    $("#star-form").submit();
  });
});

This requires you to give your star radio buttons a name of "stars" and your form to have an ID of "star-form". These can of course be changed.