ListBox的问题 有一个CheckBoxList扣一个ListBox,CheckBoxList选了后要在ListBox中立刻列出,我在服务器完成的每都刷屏,能不能不刷屏实现啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在你的aspx中<script>function setList(){ var table=document.getElementById("你的CheckBoxListID"); var list=document.getElementById("你的ListBoxID"); for(i=list.length-1;i>=0;i--) { list.options[i]=null; } var curOpt; for(i=0;i<table.rows.length;i++) { curOpt=table.rows[i].cells[0]; if(curOpt.firstChild.checked) list.options[list.length]=new Option(curOpt.innerText); }}</script>在aspx.cs中你的CheckBoxListID.Attributes.Add("onclick","setList();"); <input type="checkbox" value="2" onclick="Sel(this.value)"><select name="sel" id="sel"> <option value="1">1</option> <option value="2">2</option></select><script >function Sel(val){for (var i = 0; i < document.all.sel.length; i++){if (document.all.sel.options[i].value == val){document.all.sel.options[i].selected = true; } }} to powbcom(一搏云天):谢谢,不过我的CheckBoxList是在服务器上绑定的数据,你的方法我有试过没用 to welshem(天堂客),你的方法通过了,谢谢上面的50分给你了不过另有问题,另加30分请问:我按了确定钮后,回来的页面里ListBox空了,怎么改才能有值 好办啊,在body 中加onload="setList()" 网站里面文章被浏览N次 关于上传文件 两个问题~ asp.net 引用web service ,怎样cache住上次计算数据,下次计算会快吗? textbox内容改变的同时激发回车事件 高手指教:用户登陆完美解决方案? 关于一个退出按钮的问题! 搜索的时候只能得到英文结果 写aspx页面的时候经常出现不能转到“设计”页面的烦恼! web.config文件是干什么用的? 在asp.net中编号用guid合适吗? 用户控件用使用WEB控件?
<script>
function setList()
{
var table=document.getElementById("你的CheckBoxListID");
var list=document.getElementById("你的ListBoxID");
for(i=list.length-1;i>=0;i--)
{
list.options[i]=null;
}
var curOpt;
for(i=0;i<table.rows.length;i++)
{
curOpt=table.rows[i].cells[0];
if(curOpt.firstChild.checked)
list.options[list.length]=new Option(curOpt.innerText);
}
}
</script>
在aspx.cs中
你的CheckBoxListID.Attributes.Add("onclick","setList();");
<select name="sel" id="sel">
<option value="1">1</option>
<option value="2">2</option>
</select>
<script >
function Sel(val){
for (var i = 0; i < document.all.sel.length; i++){
if (document.all.sel.options[i].value == val){
document.all.sel.options[i].selected = true; }
}
}
上面的50分给你了不过另有问题,另加30分请问:我按了确定钮后,回来的页面里ListBox空了,怎么改才能有值