listbox 三级联动

liu_liushi85 2009-12-29 05:13:21
有一个下拉列表框

有三个listbox

当我选择下拉列表框里的内容时 三个listbox会自动的出现想对应的内容(用js实现)

各位大虾 能把代码贴出来看看

...全文
105 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wenblue7 2009-12-29
  • 打赏
  • 举报
回复
ding
wuyq11 2009-12-29
  • 打赏
  • 举报
回复
function SelectAll()
{
var lst1=window.document.getElementById("SourceListBox");
var length = lst1.options.length;
for(var i=0;i<length;i++)
{
var v = lst1.options[i].value;
var t = lst1.options[i].text;
var lst2=window.document.getElementById("DestinationListBox");
lst2.options[i] = new Option(t,v,true,true);
}

}

function DelAll()
{
var lst2=window.document.getElementById("DestinationListBox");
var length = lst2.options.length;
for(var i=length;i>0;i--)
{
lst2.options[i-1].parentNode.removeChild(lst2.options[i-1]);
}
}

function SelectOne()
{
var lst1=window.document.getElementById("SourceListBox");
var lstindex=lst1.selectedIndex;
if(lstindex<0)
return;
var v = lst1.options[lstindex].value;
var t = lst1.options[lstindex].text;
var lst2=window.document.getElementById("DestinationListBox");
lst2.options[lst2.options.length] = new Option(t,v,true,true);

}

function DelOne()
{
var lst2=window.document.getElementById("DestinationListBox");
var lstindex=lst2.selectedIndex;
if(lstindex>=0)
{
var v = lst2.options[lstindex].value+";";
lst2.options[lstindex].parentNode.removeChild(lst2.options[lstindex]);
}

}
_0筱筱0_ 2009-12-29
  • 打赏
  • 举报
回复
AJAX可以实现....需要的化我可以给你实例.....
archu 2009-12-29
  • 打赏
  • 举报
回复
他可能只是静态的数据而已。
google随便搜一下就有很多javascript写的例子。
lovexilove 2009-12-29
  • 打赏
  • 举报
回复
这种联动不用AJAX根本不可能取到值
  • 打赏
  • 举报
回复
放到updataPanel
里面就行了
手抓宝 2009-12-29
  • 打赏
  • 举报
回复
js实现只有ajax了
chaofd 2009-12-29
  • 打赏
  • 举报
回复
mk

62,254

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧