0
如何使用另一個ddl填充ddl,並且符合Internet Explorer,同時仍然可以穿過選項陣列來設置所選選項?JavaScript:使用IE合規性傳輸DDL's
/*******************************************************************************
* Function: func_copy_all
* Created By: A. Fulton
* Created Date: 3/8/2013
* For Release or Issue: RSP5.02
* Modified Date:
* Purpose: Populate city ddls and selecteds.
*******************************************************************************/
function func_copy_all()
{
var ln_start_location = ((Number(document.getElementById('page_index').value) - 1) * Number(document.getElementById('page_size').value)) +1;
for(i = ln_start_location; i < (ln_total_rows + 1); i++){
//load the current city ddl with options
var lo_city = document.getElementById('city_'+i);
var lo_temp_city = document.getElementById('temp_city_selection');
/*For IE*/
var node = document.getElementById('city_cell_' + i);
var lo_cell = document.createElement("TD");
var lo_textNode = document.createTextNode(lo_temp_city);
lo_cell.appendChild(lo_textNode);
node.appendChild(lo_cell);
//Believe innterHTML inside a div might be a problem for IE
//lo_city.innerHTML = lo_temp_city.innerHTML;
//option value that needes to be selected
var ls_selected_city = document.getElementById('city2_'+i).value;
//Get the length of the ddl
var optCount = lo_temp_city.options.length;
//Traverse the array to get the index and set it to the city to selected
for(var ln_j = 0; ln_j < optCount; ln_j++){
if(lo_temp_city.options[ln_j].value == ls_selected_city){
//set selected and break
lo_city.options[ln_j].selected = "true";
//break
ln_j = optCount + 1;
}
}
}
}
如果我使用innerHTML的,但不使用IE瀏覽器,我可以使用firefox正常工作嗎?如果我避免了innerHTML,我有一個文本節點,我無法遍歷來設置選定的值。
你是什麼意思由[「ddl」](http://acronyms.thefreedictionary.com/DDL)? – Bergi 2013-03-14 18:53:45
「*在div中相信innterHTML可能是IE *的一個問題*」 - 爲什麼?我不同意這種看法。你試過了嗎,你有錯誤嗎? – Bergi 2013-03-14 18:56:46
下拉列表。我的意思是選擇標籤。當我使用innerHTML時,我可以很好地使用Firefox,但我無法確定這是問題所在。我的一位同事表示可能是這個問題。我正在運行IE8。 – bearcatFulton 2013-03-15 14:49:42