我有这个选择框,如果我选择其他文本框会显示,问题是我放在那里的数据只得到值"其他"即使我把文字放在文本框中,它得到的唯一价值就是"其他"那么你建议我做什么呢? 我使用$ _POST [' talent']来获取价值。
Talent:
<select name="talent" onchange="if( this.value=='other' ) { this.form['other'].style.visibility='visible' }else { this.form['other'].style.visibility='hidden' };" required/>
<option value="Dancing">Dancing</option>
<option value="Singing">Singing</option>
<option value="other">Other</option>
<input type="text" name="other" style="visibility:hidden;" />
</select>
答案 0 :(得分:3)
$_POST['talent']
只会返回select元素的值。如果该值为“other”,则表示用户已选择该选项。在这种情况下,您需要$_POST['other']
才能获得他们在框中输入的值。
$talent = $_POST['talent'];
if ($talent === 'other')
$talent = $_POST['other'];
答案 1 :(得分:0)
您需要使用$_POST['other']
来获取文本框的内容。此外,您需要将文本框放在</select>
。