search

Home  >  Q&A  >  body text

Click multiple choice questions

<input type="radio" name="gender" id="male"><label for="male">male</label>

<input type= "radio" name="nvde" id="nv"><label for="nv">female</label>

This is what I wrote, but when one is selected, the other state No change, what did I write wrong?

笑书神侠笑书神侠2692 days ago1469

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-07-15 10:25:18

    Radio is a single option, and the names in it must be consistent. Your name="gender" above and name="nvde" below are equal to two single options. Of course, the status of the other one remains unchanged

    reply
    0
  • 天蓬老师

    天蓬老师2017-07-14 23:00:08

    The correct syntax should be written like this:

    <label for="male">男</label>
    <input type="radio" name="sex" id="male" />
      
    <label for="female">女</label>
    <input type="radio" name="sex" id="female" />

    Because the radio button control can only select one at a time, no matter how many radios there are, their name attribute values ​​must be the same, so as to ensure that only one value is passed to the server deal with.

    In your code, the first line, name="gender", the second line: name="nvde", the name values ​​here must be the same.

    Please modify it before running it.

    reply
    1
  • Cancelreply