+ 2
How to get the input radio to work?
I know that if you give the yser a choice you need to write <input type="radio"/>. But now I want the selection the user chose to automatically, let's say, calculate something which he wouldn't have gotten if he had chosen the other radio button. How do I achieve that?
6 Réponses
+ 2
It better be done on client side using Javascript.
Check out this code, use Javascript to condition the other inputs based on radio selected input.
https://code.sololearn.com/Wg0znSMd76kD/?ref=app
+ 1
Ok thanks both of you
+ 1
Although it might be better in javascript (Im not sure as I dont know much JS yet) it is also possible to prevent multiple selection with just html by using the name attribute to link them.
For example, adding a name attribute of "gender" to 2 radio fields would stop you from selecting both. (Im assuming this is the problem you're having)
This may be useful
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio
+ 1
Thanks a lot
0
if youre just using JS then you can use the onchange event
0
Do you have to use JS? Haven't done that yet. Learning JS on my to-do-list :)