大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> ASP专区 -> (排序,连选,跳选多项Option)下拉列表框1下拉列表框(改进版)

(排序,连选,跳选多项Option)下拉列表框1下拉列表框(改进版)

时间: 2021-07-31 作者:daque

证明: 是 上 一 回 程 式 的 改 进 版!本程式扶助排序,shift和ctrl功效!(即:连选和跳选多项option)不妨大肆的彼此操纵(下拉列表框1<=>下拉列表框2)!即使多维数组搀杂,不妨本人写一个排序因变量!javascript中sort()所传的参数为数组的俩个record(我的设置),默许按字符排序。排序所传的参数也为一个数组,例数组a 为下所示:a[0][0]=1;a[0][1]=2;a[0][2]=3;a[0][3]=4;a[1][0]=1;a[1][1]=2;a[1][2]=3;a[1][3]=4;a[2][0]=1;a[2][1]=2;a[2][2]=3;a[2][3]=4;历次所传的参数为下:a[0]={1,2,3,4}a[1]={1,2,3,4}。。。。。。。那么本人按照诉求就不妨对传来的参数数组(本质为数组中的record)中的某一个field举行排序!select.htm<html><head><meta content="text/html; charset=utf8" http-equiv=content-type><link rel="stylesheet" href="common.css"></head><body bgcolor=skyblue><form action="select.htm" method="post" name="myform"><br><br><br><div align="center"><center><left><table style="font-size: smaller"><tr><td> <table> <tr><td> <select name="left_select" style="height: 200px; width: 100px" multiple> <option value="a">a</option><option value="b">b</option> <option value="c">c</option><option value="d">d</option> <option value="e">e</option><option value="f">f</option> <option value="g">g</option><option value="h">h</option> <option value="i">i</option><option value="j">j</option> <option value="k">k</option><option value="l">l</option> <option value="m">m</option><option value="n">n</option> <option value="o">o</option><option value="p">p</option> </select> </td></tr>  </td><td> <table border="0">  <br> <tr><td> <input language="javascript" name="btn_select_addany" onclick="fun_select_addany(document.myform)" style="color: blue; font-family: webdings; font-size: 12pt; font-weight: normal; height: 28px; width: 27px" title="add any" type=button value="8"></td></tr><tr><td> <input language="javascript" name="btn_select_addall" onclick="fun_select_addall(document.myform)" style="color: blue; font-family: webdings; font-size: 12pt; font-weight: normal; height: 28px; width: 27px" title="add all" type=button value=: designtimesp="17713"></td></tr><tr><td> <br><br></td></tr><tr><td> <input language="javascript" name="btn_select_dltany" onclick="fun_select_dltany(document.myform)" style="color: blue; font-family: webdings; font-size: 12pt; font-weight: normal; height: 28px; width: 27px" title ="delete any" type=button value="7"></td></tr><tr><td> <input language="javascript" name="btn_select_dltall" onclick="fun_select_dltall(document.myform)" style="color: blue; font-family: webdings; font-size: 12pt; font-weight: normal; height: 28px; width: 27px" title ="delete all" type=button value="9"></td></tr> <tr><td></td></tr> <tr><td> </td></tr> </td><td>  <table style="font-size: smaller"> <tr><td> <select name="right_select" style="height: 200px; width: 100px" multiple> </select> </td></tr>  </td></tr></tbody></table></div></center></form> </body></html><script language="javascript">function fun_select_addany(theform){var i; for (i=0;i<theform.left_select.length;i++){if (theform.left_select.options[i].selected == true){ theform.right_select.options[theform.right_select.length]=new option(theform.left_select.options[i].text); theform.left_select.options.remove(i); i--;} }sort_select(document.myform);} function fun_select_addall(theform){var i; for (i=0;i<theform.left_select.length;i++){theform.right_select.options[theform.right_select.length]=new option(theform.left_select.options[i].text);}theform.left_select.length=0; sort_select(document.myform); }function fun_select_dltany(theform){ var i;  for (i=0;i<theform.right_select.length;i++){ if (theform.right_select.options[i].selected == true){theform.left_select.options[theform.left_select.length]=new option(theform.right_select.options[i].text);theform.right_select.options[i] =new option("");theform.right_select.options.remove(i);i--; }  } sort_select(document.myform);}function fun_select_dltall(theform){var i; for (i=0;i<theform.right_select.length;i++){theform.left_select.options[theform.left_select.length]=new option(theform.right_select.options[i].text);}theform.right_select.length=0;sort_select(document.myform);}function sort_select(theform){var i; var left_array= new array();var right_array = new array();for (i=0;i<theform.left_select.length;i++){left_array[i] = new array(theform.left_select.options[i].text);}for (i=0;i<theform.right_select.length;i++){right_array[i] = new array(theform.right_select.options[i].text);}left_array.sort();right_array.sort();theform.left_select.length=0;theform.right_select.length=0;for (i=0;i<left_array.length;i++){theform.left_select.options[theform.left_select.length]=new option(left_array[i]);}for (i=0;i<right_array.length;i++){theform.right_select.options[theform.right_select.length]=new option(right_array[i]);}left_array= new array();right_array = new array();} </script>

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.