select javascript

来源:百度知道 编辑:UC知道 时间:2024/05/29 15:48:46
<option><select onchange="document.getElementById('getFlag').style.display='block';document.getElementById('getFlag').src=this.childNodes[this.SelectedIndex].title" name="UserCountry">............

上面一段有问题不。。我怎么'getFlag'这个图片不能正常显示,总显示脚本错误
那个option写倒了,总是提示 document.getElementById(...).options[...].title' 为空或不是对象

this.childNodes[this.SelectedIndex].title我一般都是this.options[this.SelectedIndex].text,例如下面的代码是可以工作的:

<select onchange="alert(this.options[this.selectedIndex].text);">
<option value=11>11.xxx
<option value=22>22.yyy
</select>

如果要显示每个选项的value,那么就使用this.options[this.SelectedIndex].value,你那样是否正确我没有测试,你的脚本错误的具体信息是什么呢?

你的select怎么是被<option>包围的
遇到这种问题先检查你的html标签是否正确嵌套、正确闭合
把事件写在标签上很不直观,建议另写独立的js函数

你的option怎么在select的外边?