列表选择问题

guofu_9070 2008-04-03 10:19:52
2个ListBox,2个按钮,选择ListBox1中的一个值,点一个按钮当前值移到ListBox2中去,ListBox1的当前值消失,要用JS写,不刷新页面,请高人指点
...全文
63 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
guofu_9070 2008-04-03
  • 打赏
  • 举报
回复
我原来只用过,asp,没用过。NET
guofu_9070 2008-04-03
  • 打赏
  • 举报
回复
按钮事件怎么写啊
<asp:Button ID="Button3" runat="server" Text="-->" OnClick="SelectOne()" /><p />怎么没办法编译呢
“ASP.documentmanage_adddoc_aspx”并不包含“SelectOne”的定义
guofu_9070 2008-04-03
  • 打赏
  • 举报
回复
我页面上还用到FileUpload控件,不用JS的话选择一次FileUpload清空一次,很是郁闷
lem12 2008-04-03
  • 打赏
  • 举报
回复

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]);
}

}
lihongdian 2008-04-03
  • 打赏
  • 举报
回复
首先告诉你,不需要用js写.因为你用js写完还是要传到后台.其次这种操作不怎么费,所以用后台自己写就可以了

62,074

社区成员

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

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

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

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