比如说我要在dropdownlist里添加1975-2000的年份,怎么样在javascript中通过循环添加数据?
js该怎么写?
js该怎么写?
解决方案 »
- .net网站,怎么做地图,像天涯,google,前程无忧里的那个样子!
- 主程序中引用dll后,调试通不过的问题
- crystalReport(水晶报表的使用)VS2005 不知道数据源为何错误??????在线等待。。。。
- 用ASP.net开发网站时,网页用什么软件制作比较方面
- 上传控件!当选择好图片时,同时应该显示出来,然后看是否保存到数据库?
- Sql超級難的問題 有興趣的來看看
- 同一个用户控件能否可以根据不同的要求显示不同的内容?
- 谁能提示一下asp.net图片上传代码?谢谢了
- request.querystring("")能传数组吗?
- 重赏:用DataGrid绑定数据后,进行删除(或更新)操作能成功,但是不能刷新DataGrid中的数据。(在线等)
- 请问VS2003连sqlserver2005怎么连???
- 大家帮忙看一下。给存储过程传参数时报错。
for(i = 1975,i<=2000;i++)
d.options[d.options.length] = new Option(i,i)
Request.Form[dropdownlistID.UniqueID]得到
function getdate()
{
var d = document.getElementById("year");
for(i = 1975,i<=2000;i++)
{
d.options[d.options.length] = new option(i,i);
}
</script>
</head>
<body onload="getdate()">
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="year" runat="Server"></asp:DropDownList>年
<asp:DropDownList ID="month" runat="Server"></asp:DropDownList>月
<asp:DropDownList ID="day" runat="server"></asp:DropDownList>日
</div>
</form>
</body>这样错的原因是什么?
d = document.getElementById('<%=dropdownlistID.ClientID%>')
for(i = 1975,i<=2000;i++)
d.options.add(new Option(i,i);
</script>
------
正解!
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="year" runat="Server"></asp:DropDownList>年
<asp:DropDownList ID="month" runat="Server"></asp:DropDownList>月
<asp:DropDownList ID="day" runat="server"></asp:DropDownList>日
</div><script language="javascript" type="text/javascript">
function getdate()
{
var d = document.getElementById("year");
for(i = 1975;i<=2000;i++)
{
d.Options.add(new Option(i,i));
}
}
</script>
</form>
</body>