js为select动态添加option,使用webservice提供数据
<head runat="server">
<title>动态添加option</title>
<script>
function myclick()
{
WebService.GetDayEnum(onSuccess);
}
function onSuccess(result)
{
var myselect= document.getElementById("myselect");
for(var i=0;i<8;i++)
{
myselect.options[i] = new Option(result[i],i);
}
}
</script>
</head>
<body onload="myclick();">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService.asmx" />
</Services>
</asp:ScriptManager>
<div>
<input type="button" value="test" onclick="myclick();"/>
<select id="myselect">
</select>
</div>
</form>
</body>