CHOOSE 1 VALUE ON RADIOS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

CHOOSE 1 VALUE ON RADIOS

How can I choose one value in Two Input type="radio" in HTML and as a result, print that thing that I've chosen.

28th Jul 2019, 8:39 AM
Johnny Deguzman
Johnny Deguzman - avatar
9 Answers
+ 4
You choose one value and not more in radio, and there may be as many choices as possible. For example, we will choose the gender we have only two sexes, male and female, and therefore you make two input. You have three apples: yellow, red, green, choose one, then there will be three input.
28th Jul 2019, 9:07 AM
Anna/Аня
Anna/Аня - avatar
+ 4
Do you mean where you can see the data that the user selected?
28th Jul 2019, 9:21 AM
Anna/Аня
Anna/Аня - avatar
+ 4
You don't have the name attribute in input; it should have the same name for radio; add name = "gender" to these two inputs. 10 and 11 line.
28th Jul 2019, 9:35 AM
Anna/Аня
Anna/Аня - avatar
+ 3
Anna You are right. He didn't add name attribute that's why he is not able to select single value. And we can get selected value by attribute id.
28th Jul 2019, 9:44 AM
A͢J
A͢J - avatar
+ 2
Johnny Deguzman Using document.getElementById('').innerHTML = document.getElementById('').value;
28th Jul 2019, 10:13 AM
A͢J
A͢J - avatar
0
Anna yeah, so If I do have 2 inputs in my HTML, for example the sexes, and I only choose "Male", how can I print it out on my HTML. Using Javascript.
28th Jul 2019, 9:17 AM
Johnny Deguzman
Johnny Deguzman - avatar
0
Anna, please do visit and see my code. The "Basic Input"☺
28th Jul 2019, 9:25 AM
Johnny Deguzman
Johnny Deguzman - avatar
0
Now I added the type name, and yes and I can choose now, so how can I print out the value that I've chosen... Ps: I need Internet, poor Filipino kid <--- lol😅
28th Jul 2019, 9:55 AM
Johnny Deguzman
Johnny Deguzman - avatar
- 1
name="value"attribute name="all radio for similar value which you want" <inlut name="selector" type="radio"> <inlut name="selector" type="radio"> <inlut name="selector" type="radio">
29th Jul 2019, 10:29 AM
Md Nawab
Md Nawab - avatar