本文出自:http://tw.myblog.yahoo.com/jw!HTs7ho.eGQMRvMUJCEUkRY.ltQJARuA-/article?mid=208&prev=209&next=207&l=a&fid=19 網絡轉發,如有侵權,敬請告知刪除!
台灣黑狗兄電影timika43175u5senaywy5
兩個欄位間值的移轉
觀看效果
http://webdeveloper.earthweb.com/repository/javascripts/2005/11/753681/SelectList.html
以下為原始碼:%26lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"%26gt;
%26lt;html%26gt;%26lt;head%26gt; %26lt;title%26gt;%26lt;/title%26gt; %26lt;script language="Javascript"%26gt; %26lt;!-- function ClearList(OptionList, TitleName) { OptionList.length = 0; } function move(side) { var temp1 = new Array(); var temp2 = new Array(); var current1 = 0; var current2 = 0; var attribute; //assign what select attribute treat as attribute1 and attribute2 if (side == "right") { attribute1 = document.rep.left; attribute2 = document.rep.right; } else { attribute1 = document.rep.right; attribute2 = document.rep.left; } //fill an array with old values for (var i = 0; i %26lt; attribute2.length; i ) { temp1[current1 ] = attribute2.options[i].value; } //assign new values to arrays for (var i = 0; i %26lt; attribute1.length; i ) { if ( attribute1.options[i].selected ) { temp1[current1 ] = attribute1.options[i].value; } else { temp2[current2 ] = attribute1.options[i].value; } } //generating new options for (var i = 0; i %26lt; temp1.length; i ) { attribute2.options[i] = new Option(); attribute2.options[i].value = temp1[i]; attribute2.options[i].text = temp1[i]; } //generating new options ClearList(attribute1,attribute1); if (temp2.length%26gt;0) { for (var i = 0; i %26lt; temp2.length; i ) { attribute1.options[i] = new Option(); attribute1.options[i].value = temp2[i]; attribute1.options[i].text = temp2[i]; } } if (side == "right") { sort(%26#39;R%26#39;) } else { sort(%26#39;L%26#39;) } } function sort(side) { var iRowInsertRow, iRowWalkRow, current, insert; if (side ==%26#39;L%26#39;) { for ( iRowInsert = 0 1 ; iRowInsert %26lt;= document.all.left.length-1;iRowInsert ) { textRowInsert = document.all.left.options[iRowInsert].text;
for ( iRowWalk = 0; iRowWalk %26lt;= iRowInsert ; iRowWalk ) {
textRowCurrent = document.all.left.options[iRowWalk].text;
// We save our values so we can manipulate the numbers for // comparison current = textRowCurrent; insert = textRowInsert;
// If the value is not a number, we sort normally, else we evaluate // the value to get a numeric representation //But first we check if value is not an empty space.
if (current.charAt(0) != " " %26%26 insert.charAt(0) != " ") {
if (!isNaN(current) %26%26 !isNaN(insert)) { current= eval(current); insert= eval(insert);
} else { current = current.toLowerCase(); insert = insert.toLowerCase(); } }
if ((insert %26lt; current) %26%26 (iRowInsert != iRowWalk) %26%26 (document.all.left.options[iRowWalk].value != %26#39;null%26#39;) ) { var optionWName = new Option( document.all.left.options[iRowWalk].text,document.all.left.options[iRowWalk].value, false, false ); var optionIName = new Option( document.all.left.options[iRowInsert].text,document.all.left.options[iRowInsert].value, false, false ); document.all.left.options[iRowInsert] = optionWName; document.all.left.options[iRowWalk] = optionIName; } } } } else { for ( iRowInsert = 0 1 ; iRowInsert %26lt;= document.all.right.length-1; iRowInsert ) { textRowInsert = document.all.right.options[iRowInsert].text;
for ( iRowWalk = 0; iRowWalk %26lt;= iRowInsert ; iRowWalk ) { textRowCurrent = document.all.right.options[iRowWalk].text;
// // We save our values so we can manipulate the numbers for // comparison // current = textRowCurrent; insert = textRowInsert;
// If the value is not a number, we sort normally, else we evaluate // the value to get a numeric representation // But first we check if value is not an empty space.
if (current.charAt(0) != " " %26%26 insert.charAt(0) != " ") {
if (!isNaN(current) %26%26 !isNaN(insert)) { current= eval(current); insert= eval(insert);
} else { current = current.toLowerCase(); insert = insert.toLowerCase(); } }
if ((insert %26lt; current) %26%26 (iRowInsert != iRowWalk) %26%26 (document.all.right.options[iRowWalk].value != %26#39;null%26#39;) ) { var optionWName = new Option( document.all.right.options[iRowWalk].text,document.all.right.options[iRowWalk].value, false, false ); var optionIName = new Option( document.all.right.options[iRowInsert].text,document.all.right.options[iRowInsert].value, false, false ); document.all.right.options[iRowInsert] = optionWName; document.all.right.options[iRowWalk] = optionIName; } } } }
} //--%26gt; %26lt;/script%26gt;%26lt;/head%26gt;
%26lt;body onload=sort(%26#39;L%26#39;)%26gt;
%26lt;form name="rep" method="post"%26gt;%26lt;table%26gt;%26lt;tr%26gt;%26lt;td%26gt;%26lt;select name="left" multiple size="5" style="width=150px" width="150px"%26gt;%26lt;option value="UCLA"%26gt;UCLA%26lt;/option%26gt;%26lt;option value="LAPL"%26gt;LAPL%26lt;/option%26gt;%26lt;option value="SMPL"%26gt;SMPL%26lt;/option%26gt;%26lt;option value="Burbank"%26gt;Burbank%26lt;/option%26gt;%26lt;option value="Tarzana"%26gt;Tarzana%26lt;/option%26gt;
%26lt;option value="Encino"%26gt;Encino%26lt;/option%26gt;%26lt;/select%26gt;%26lt;/td%26gt;%26lt;td%26gt;%26lt;input type="button" value="%26gt;%26gt;" onclick="move(%26#39;right%26#39;)"%26gt;%26lt;br%26gt;
%26lt;input type="button" value="%26lt;%26lt;" onclick="move(%26#39;left%26#39;)"%26gt;%26lt;/td%26gt;%26lt;td%26gt;%26lt;select name="right" multiple size="5" style="width=150px" width="150px"%26gt;%26lt;/select%26gt;%26lt;/td%26gt;%26lt;/tr%26gt;%26lt;/table%26gt;
%26lt;/form%26gt;%26lt;/body%26gt;%26lt;/html%26gt;
創作者介紹
創作者 愛PO吧遊樂資訊網 的頭像
ipobar

愛PO吧遊樂資訊網

ipobar 發表在 痞客邦 留言(0) 人氣( 0 )