View Full Version : 求个JS代码
比如在系统中发邮件的时候在人员选择框中选择2个人员,A和B,现在A排在了B后面,我想用JS做个按钮,在选种了B后点击"上移",B就排到了A前面.这些步骤是在人员选择框中完成的
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2</title>
<script runat="server" language="C#">
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
// 给 ListBox2 和 ListBox3 赋值
if(!IsPostBack)
{
for(int i=0;i<4;i++)
{
ListBox2.Items.Add("ListBox2_"+i.ToString());
ListBox3.Items.Add("ListBox3_"+i.ToString());
}
}
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
}
// ListBox2 >> ListBox3
private void Button1_Click(object sender, System.EventArgs e)
{
if( ListBox2.SelectedItem != null)
{
ListItem tempItem = ListBox2.SelectedItem;
ListBox2.Items.Remove(tempItem);
ListBox3.Items.Add(tempItem);
ListBox3.SelectedIndex = -1;
}
}
// ListBox3 >> ListBox2
private void Button2_Click(object sender, System.EventArgs e)
{
if( ListBox3.SelectedItem != null)
{
ListItem tempItem = ListBox3.SelectedItem;
ListBox3.Items.Remove(tempItem);
ListBox2.Items.Add(tempItem);
ListBox2.SelectedIndex = -1;
}
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:ListBox id="ListBox2" style="Z-INDEX: 101; LEFT: 88px; POSITION: absolute; TOP: 200px" runat="server"
Width="96px" Height="128px"></asp:ListBox>
<asp:ListBox id="ListBox3" style="Z-INDEX: 102; LEFT: 240px; POSITION: absolute; TOP: 200px"
runat="server" Width="96px" Height="120px"></asp:ListBox>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 104px; POSITION: absolute; TOP: 152px" runat="server"
Text=" >> "></asp:Button>
<asp:Button id="Button2" style="Z-INDEX: 104; LEFT: 256px; POSITION: absolute; TOP: 152px" runat="server"
Text=" << "></asp:Button>
</form>
</body>
</HTML>
兄弟收了,那是相当的有用..但是要是能把流汗的小人去掉就更好了
呵呵 这个是asp的代码 你可以把它转化为js代码即可
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.