我无法使以下代码正常工作....
<H3>Select your Office Location:</H3>
<SELECT id=selOption onchange=goToUrl(this.value)><OPTION selected>--Select--</OPTION>
<OPTION value=/sites/rnd2/products/ITC/operations/Lists/802%20%20Australia%20Barton%20survey/NewForm.aspx>802 - Australia, Barton</OPTION>
<OPTION value=/sites/rnd2/products/ITC/operations/Lists/852%20%20Australia%20Melbourne%20survey/NewForm.aspx>852 - Australia, Melbourne survey</OPTION>
<OPTION value=/sites/rnd2/products/ITC/operations/Lists/855%20%20Australia%20North%20Ryde%20%20Survey/NewForm.aspx>855 - Australia, North Ryde Survey</OPTION>
<OPTION value=/sites/rnd2/products/ITC/operations/Lists/864%20%20Australia%20Applecross%20%20Survey/NewForm.aspx>864 - Australia, Applecross Survey</OPTION>
...
</select>
它一直给我“对象预期”错误。
请帮助..
答案 0 :(得分:0)
您必须在每个HTML属性上设置“如下:
<SELECT id="selOption" onchange="goToUrl(this.value)">
答案 1 :(得分:0)
原因是在您使用之前必须指定goToUrl()
:
<script>
function goToUrl(url) {
window.location = url;
}
</script>
<SELECT id="selOption" onchange="goToUrl(this.value)">
这是fiddle。
此外,您的html属性值应该用引号括起来。