我有这个简单的代码,它在我的谷歌浏览器上运行良好,但无法在 IE 8 上运行。当选择一个选项时,该值总是为空。
<form target="_self" method="post" action="index.pl" name="set_filter">
<select name="project" onChange='window.location="index.pl?project=" + this.value'>
<option selected="selected"></option>
<option>1</option>
<option>2</option>
</form>
当我从列表中选择一个选项 (1) 时,url 设置为 http://myserver.com/tests/index.pl?project=
在 Google 上我做对了:http://myserver.com/tests/index.pl?project=1
有什么想法或替代方案吗?
最佳答案
你应该使用 this.options[this.selectedIndex].text
关于javascript - 无法从 SELECT 中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21836271/