[英]Form with radio button
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 $_POST["sex"]
获得“男性”或“女性”的价值或他们选择的内容
You should set their name
attribute to "sex" and have them carry diffrerent values: 你应该将他们的
name
属性设置为“sex”并让它们带有不同的值:
<input type="radio" name="sex" value="female" />Female<br />
<input type="radio" name="sex" value="male" />Male<br />
radiobuttons的name
必须相同,而不是id(id 必须是唯一的)
You need to give them the same name
(the name of the radio button group) attribute and different id
attributes to work: 您需要为它们指定相同的
name
(单选按钮组的名称)属性和不同的id
属性:
<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>
i think than all radio button inputs in one group must have the same 'name' attribute: 我认为,一组中的所有单选按钮输入必须具有相同的“名称”属性:
Kvinna Båda KvinnaBåda
Man 男人
$_POST['sex'] returns are element value with name attribute "sex". $ _POST ['sex']返回的是元素值,名称属性为“sex”。 For use it - set all radiobutons name to "sex".
使用它 - 将所有radiobutons名称设置为“sex”。
Just switch your name
attributes with your id
attributes. 只需使用您的
id
属性切换您的name
属性。 So instead of 而不是
<input id="sex" name="sexFemale" ...
just use 只是用
<input id="sexFemale" name="sex" ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.