我有一个选择选项,如下所示。
<select name = "type">
<option value="">Select one</option>
<option value="1">Abc</option>
<option value="2">Xyz</option>
</select>
我尝试使用Input::get('type')
获取值,但获取标签Abc
。我需要将值设为1
或2
或3
,具体取决于我选择的值。我甚至试过这个
<select name = "type" onchange="document.getElementById('typeId').value=this.options[this.selectedIndex].value;">
但同样的事情发生了。我怎么能这样做?
答案 0 :(得分:1)
只需
document.getElementById('typeId').value=this.value;