Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting a radio button isn't an event?

I have a html form which contains group of radio buttons.

When one of them is selected, the form attribute "action" should be executed as well as the method "get".

But the problem is, selecting the radio button doesn't recognized as an event !!

and if I changed the radio buttons to submit buttons the click on the submit button will be recognized as an event and the action will take place, do you have any idea why??

like image 544
Lisa Avatar asked Nov 25 '25 21:11

Lisa


1 Answers

HTML forms do not submit unless someone presses a submit button.

You can use Javascript to get your radio buttons to submit the form:

<input type="radio" onclick="this.form.submit();" />

Be aware, however, that a radio button that submits the form is something a user generally does not expect. Use with caution.

like image 148
Håvard S Avatar answered Nov 28 '25 09:11

Håvard S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!