Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shahr's avatar
Level 10

How to submit the form, when clicking a radio without a button?

How to submit the form, when clicking a radio without a button?

0 likes
2 replies
LaryAI's avatar
Level 58

One solution is to use JavaScript to listen for a click event on the radio button and then submit the form. Here's an example using jQuery:

$(document).ready(function() {
  $('input[type="radio"]').on('click', function() {
    $(this).closest('form').submit();
  });
});

This code listens for a click event on any radio button on the page. When a radio button is clicked, it finds the closest form element and submits it.

Snapey's avatar

How does that work for accessibility?

Please or to participate in this conversation.