从列表框中删除项目 [英] Remove item from list box

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

问题描述

我有两个列表框,说A和B绑定了相同的数据源。如果我从列表框A中选择项目并且我删除了该项目,那么它也应该从列表框B中删除。

I have two listbox say A and B binded with same datasource. If i select item from listbox A and i removed that item then it should also be removed from list box B.

推荐答案

你好,



由于两个选择框都绑定到同一个数据源,您可以编写类似于下面所示的客户端javascript函数来删除项目。
Hello,

Since both the select boxes are bound to the same data source you can write the client side javascript function similar to one shown below to delete the items.
function removeItem() {
    var s1 = document.getElementById('s1');
    var idx = s1.selectedIndex;
    if (s1 && idx > -1) {
        s1.remove(idx);
        var s2 = document.getElementById('s2');
        s2.remove(idx);
    }
}



问候,


Regards,


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

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