移動到右邊的,為什麼要選中後提交才能擷取到相應的值。該怎麼解決

來源:互聯網
上載者:User
移動到右邊的,為什麼要選中後提交才能擷取到相應的值。
本帖最後由 qq914260102 於 2013-10-14 16:02:07 編輯

如果選到右邊,是無法擷取到值的,必須要點擊一次,選中了才能擷取到,怎麼讓右邊的預設能擷取值

sortitems = 1;  // Automatically sort items within lists? (1 or 0)
function move(fbox,tbox) {
for(var i=0; iif(fbox.options[i].selected && fbox.options[i].value != "") {
var no = new Option();
no.value = fbox.options[i].value;
no.text = fbox.options[i].text;
tbox.options[tbox.options.length] = no;
fbox.options[i].value = "";
fbox.options[i].text = "";
}
}
BumpUp(fbox);
if (sortitems) SortD(tbox);
}
function BumpUp(box) {
for(var i=0; iif(box.options[i].value == "") {
for(var j=i; jbox.options[j].value = box.options[j+1].value;
box.options[j].text = box.options[j+1].text;
}
var ln = i;
break;
}
}
if(ln < box.options.length) {
box.options.length -= 1;
BumpUp(box);
}
}
function SortD(box) {
var temp_opts = new Array();
var temp = new Object();
for(var i=0; itemp_opts[i] = box.options[i];
}
for(var x=0; xfor(var y=(x+1); yif(temp_opts[x].text > temp_opts[y].text) {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
temp = temp_opts[x].value;
temp_opts[x].value = temp_opts[y].value;
temp_opts[y].value = temp;
}
}
}
for(var i=0; ibox.options[i].value = temp_opts[i].value;
box.options[i].text = temp_opts[i].text;
}
}

分享到:


------解決方案--------------------
懶得看代碼理解,純想象
form提交,select只提交選擇的option
所以如果要提交list2,要把全部都加設selected屬性,或者把option的每個value都賦值一個新控制項(例如hidden)來提交
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.