[英]send mail form - get value from radio button
I have already tried many solutions I found on this site but I can't seem to figure this out.我已经尝试了在这个网站上找到的许多解决方案,但我似乎无法弄清楚这一点。
My radio buttons:我的单选按钮:
<input type="radio" id="radio1" name="apartman" />
<label for="radio1">Apartman 1</label>
<input type="radio" id="radio2" name="apartman" />
<label for="radio2">Sunny Shit 2</label>
<input type="radio" id="radio3" name="apartman" />
<label for="radio3">Penthouse</label>
<input type="radio" id="radio4" name="apartman" />
<label for="radio4">Rupčaga</label>
<input type="radio" id="radio5" name="apartman" />
<label for="radio5">Štala Gold Class</label>
And this is the PHP I got in mailing script:这是我在邮件脚本中得到的 PHP:
$apartman = $_POST['apartman'];
The result I keep geting in my mail is:我不断收到邮件的结果是:
Apartman: on公寓:开
Result I want to get:我想得到的结果:
Apartman: [value of selected radio button]公寓:[所选单选按钮的值]
The only thing that differenciates each of your radio buttons is the id
attribute, however the ID is not used in calculating the form data, you also need to add a value
attribute to each of your radio buttons, and you will get the desired effect:唯一区分每个单选按钮的是
id
属性,但是 ID 不用于计算表单数据,您还需要为每个单选按钮添加value
属性,您将获得所需的效果:
<input type="radio" id="radio1" name="apartman" value="radio1" />
<label for="radio1">Apartman 1</label>
<input type="radio" id="radio2" name="apartman" value="radio2" />
<label for="radio2">Sunny Shit 2</label>
<input type="radio" id="radio3" name="apartman" value="radio3" />
<label for="radio3">Penthouse</label>
<input type="radio" id="radio4" name="apartman" value="radio4" />
<label for="radio4">Rupčaga</label>
<input type="radio" id="radio5" name="apartman" value="radio5" />
<label for="radio5">Štala Gold Class</label>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.