开发者

Javascript running improperly?

开发者 https://www.devze.com 2022-12-23 21:50 出处:网络
I have a Javascript function that is called from the onchange method in a DropDownList. However I\'m getting the error \"Cannot have multiple items selected in a DropDownList.\" on line 14. This happe

I have a Javascript function that is called from the onchange method in a DropDownList. However I'm getting the error "Cannot have multiple items selected in a DropDownList." on line 14. This happens when the page is reloaded for other purposes. Why is it getting hung here when the method shouldn't even be getting called?

Line 12: {
Line 13:     var hfSelected = document.getElementById("<%=hfSelectedValu开发者_高级运维e.ClientID%>");
Line 14:     var ddlExposure = document.getElementById("<%=ddlExposure.ClientID%>");
Line 15:     hfSelected.value = ddlExposure.options[ddlExposure.selectedIndex].text + "|" + ddlExposure.options[ddlExposure.selectedIndex].value;
Line 16: }


Your page is still performing a post back and filling out the inline ASP.Net code on your page during that time.

Clear out your selections before setting the value, that should fix it.

hfSelected.value = '';

0

精彩评论

暂无评论...
验证码 换一张
取 消