select 上移下移删除以及模态对话框

 
< html  xmlns ="http://www.w3.org/1999/xhtml"   >
< head >
    
< title > 4.1对话框 </ title >
< script  language ="javascript"  type ="text/javascript" >
// <!CDATA[
function Button3_onclick() {
//下移
Select1.options.insertBefore(Select1.options[Select1.selectedIndex+1],Select1.options[Select1.selectedIndex]);
}

function Button1_onclick()
{
//添加
   var s= window.showModalDialog("dialog.htm","","dialogHeight:200px;dialogWidth:300px");
  
    
var coll = document.all.tags("SELECT");
    
if (coll.length>0)
    
{
         
for (i=0; i< coll(0).options.length; i++)
        
{
             
if (s[0]==coll(0).options(i).value)
             
{
                  window.alert(
"该用户已经存在!");
                  
return;
             }

         }

    }

  
    
   
var oOption = document.createElement("OPTION");
    Select1.options.add(oOption);
    oOption.innerText
=s[0]+"-"+s[1];
    oOption.value
=s[0];
}

function Button2_onclick() {
//删除
Select1.remove(Select1.selectedIndex);
}

function Button4_onclick() {
//上移
Select1.options.insertBefore(Select1.options[Select1.selectedIndex],Select1.options[Select1.selectedIndex-1]);
}

// ]]>
</ script >
</ head >
< body >
    
< select  id ="Select1"  multiple ="multiple"  style ="width: 112px" >
    
</ select >
    
< br  />
    
< input  id ="Button1"  type ="button"  value ="添加用户"  onclick ="return Button1_onclick()"   /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    
< input  id ="Button4"  type ="button"  value ="上移"  onclick ="return Button4_onclick()"   />
    
< input  id ="Button3"  type ="button"  value ="下移"  onclick ="return Button3_onclick()"   />
    
< input  id ="Button2"  type ="button"  value ="删除"  onclick ="return Button2_onclick()"   />
   
</ body >
</ html >
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值