我有我的aspx頁面10個列表框中的所有10個列表框相同的功能正在使用一些按鈕我想添加列表框數據到網格可以幫助我我的Java腳本下面所示回發生在asp.net丟失的javascript列表框項目
function MoveItem(ctrlSource, ctrlTarget) {
var Source = document.getElementById(ctrlSource);
var Target = document.getElementById(ctrlTarget);
if ((Source != null) && (Target != null)) {
while (Source.options.selectedIndex >= 0) {
var newOption = new Option(); // Create a new instance of ListItem
newOption.text = Source.options[Source.options.selectedIndex].text;
newOption.value = Source.options[Source.options.selectedIndex].value;
Target.options[Target.length] = newOption; //Append the item in Target
Source.remove(Source.options.selectedIndex); //Remove the item from Source
}
}
}
我試圖上面的代碼一個JavaScript使用HTML輸入按鈕問題時,我試圖保存listbox.items.count給予0誰能告訴移動列表框之間的物品代碼我爲什麼會發生這種情況,以及何時發回帖子列表框項目丟失。
您可以使用jQuery在Listbox之間傳輸項目:http://dpatri.com/technology/jquery/move-list-box-items-from-left-to-right-using-jquery/ – 2011-01-06 12:25:53