Nick Pocock Nick Pocock - 1 year ago 122
HTML Question

Only allow one radio button to be checked HTML

I have a series of radio buttons in which i'd only like 1 to be able to be selected. I have them all with the same name so I thought this would do the trick but i can still select all four.


<input type="radio" name="portion_num" value="2" /> Two

<input type="radio" name"portion_num" value="4" /> Four

<input type="radio" name"portion_num" value="6" /> Six

<input type="radio" name"portion_num" value="8" /> Eight

Answer Source

The reason it doesn't work is because your name attribute syntax is wrong.

name"portion_num" should be name="portion_num"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download