< 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()" /> < 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 >