Hello guys,I have a question bout radio button.
I can not run this code! I do not know where is wrong! please help me
my code:
...
<form action="/submit-cat-photo">
***<input id='indoor' type='radio' name='indoor-outdoor' >***
*** <label for='indoor'>Indoor</label>***
*** <input id='outdoor' type='radio' name='indoor-outdoor' >***
*** <label for='outdoor'>Outdoor</label>***
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
mcalex
May 12, 2019, 10:09am
2
I copied your code to jsfiddle and (after deleting all the asterisks) found the radio buttons are working properly. If you check outdoor
, indoor
becomes unchecked, if you check indoor
, outdoor
becomes unchecked.
What are the buttons doing wrong?
Unfortunately, it does not run in site!
Indoor
Outdoor
Submit
I put error Message for you.
running tests:
Give your radio buttons the name attribute of indoor-outdoor.
Each of your two radio button elements should be nested in its own label element.
mcalex
May 12, 2019, 10:53am
4
There’s the problem:
So, your structure should look like:
<label><input></label>
You don’t have each radio button nested in its own label
, your input
s and label
s are at the same level.