tags:

views:

26

answers:

6

I have this:

<td>
    <input id="sex" name="sexFemale" value="female" type="radio">
    <label for="sexFemale">
        Kvinna
    </label>
</td>
<td>
    <input id="sex" name="sexBoth" value="both" checked="checked" type="radio">
    <label for="sexBoth">
        Båda
    </label>
</td>
<td>
    <input id="sex" name="sexMale" value="male" type="radio">
    <label for="sexMale">
        Man
    </label>
</td>

I think I made this wrong, how should I use it?

$_POST["sex"] to get the value "male" or "female" or what they chosed

+2  A: 

You should set their name attribute to "sex" and have them carry diffrerent values:

<input type="radio" name="sex" value="female" />Female<br />
<input type="radio" name="sex" value="male" />Male<br />
kender
A: 

the name of the radiobuttons has to be the same, not the id (the id must be unique)

oezi
A: 

i think than all radio button inputs in one group must have the same 'name' attribute:

Kvinna Båda
Man

heximal
A: 

$_POST['sex'] returns are element value with name attribute "sex". For use it - set all radiobutons name to "sex".

Drakmail
A: 

You need to give them the same name (the name of the radio button group) attribute and different id attributes to work:

<td>
  <label><input id="sexFemale" name="groupSex" value="female" type="radio">
  Kvinna</label>
</td>
<td>
  <label><input id="sexBoth" name="groupSex" value="both" checked="checked" type="radio">
  Båda</label>
</td>  
<td>
  <label><input id="sexMale" name="groupSex" value="male" type="radio">
  Man</label>
</td>
Andrew Dunn
A: 

Just switch your name attributes with your id attributes. So instead of

<input id="sex" name="sexFemale" ...

just use

<input id="sexFemale" name="sex" ...
poke