在双列表框中移动项目 [英] Moving items in Dual Listboxes

查看:9
本文介绍了在双列表框中移动项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 ASP.NET 中使用 JavaScript 将项目从一个列表框控件移动到另一个列表框控件?

How can I move items from one list box control to another listbox control using JavaScript in ASP.NET?

推荐答案

此代码假定您有一个锚点,或者当它被点击时会触发移动:

This code assumes that you have an anchor or that will trigger to movement when it is clicked:

document.getElementById('moveTrigger').onclick = function() {

    var listTwo = document.getElementById('secondList');
    var options = document.getElementById('firstList').getElementsByTagName('option');

    while(options.length != 0) {
        listTwo.appendChild(options[0]);
    }

 }

这篇关于在双列表框中移动项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆