请教关于2个listbox之间数据互相传递的问题,要使用js
需求就是2个listbox之间有4个按钮,添加,全部添加,移除,全部移除,哪位高手有js的代码让小弟参考下 --------------------编程问答-------------------- 如果不想写js的话,可以使用微软的Ajax框架来实现,简单方便 --------------------编程问答-------------------- 楼上的大哥,我就是想用js写啊,Ajax框架没怎么涉及过,有js的代码让我参考嘛 --------------------编程问答-------------------- <script language="javascript">var listbox1 = null;
var listbox2 = null;
function window.onload()
{
listbox1 = document.getElementById("ListBox1");
listbox2 = document.getElementById("ListBox2");
}
function add()
{
if(listbox1.selectedIndex == -1)
{
window.alert('请先选择ListBox1数据项!');
return;
}
listbox2.options[listbox2.length] = new Option(listbox1.options [listbox1.selectedIndex].text,listbox1.options[listbox1.selectedIndex].value);
listbox1.options[listbox1.selectedIndex] = null;
}
function addall()
{
var init_index = listbox2.length;
var count = listbox1.length;
for(var i=0;i<count;i++)
{
var index = init_index +i;
listbox2.options[index] = new Option(listbox1.options [0].text,listbox1.options[0].value);
listbox1.options[0] = null;
}
}
</script>
限于篇幅,这里只贴出添加和全部添加代码
移除可以类推,不再赘述
补充:.NET技术 , ASP.NET