日期:2014-05-16  浏览次数:20377 次

js二维数组遍历,select选中状态,设置input默认值

//方案3.2恢复默认值
var array32=new Array();
???? array32 =[
???? ['show',10,'plan3_2_1'],['show',10,'plan3_2_2'],['show',120,'plan3_2_3'],['show',120,'plan3_2_4'],
???? ['show',30,'plan3_2_5'],['show',30,'plan3_2_6'],['show',5,'plan3_2_7'],['show',10,'plan3_2_8'],
???? ['show',10,'plan3_2_9'],['show',2,'plan3_2_10'],['show',2,'plan3_2_11'],['show',1,'plan3_2_12'],
???? ['show',1,'plan3_2_13'],['show',1,'plan3_2_14'],['show',2,'plan3_2_15'],['show',2,'plan3_2_16'],
???? ['0',0,'plan3_2_17']
???? ];
? for(var i=0;i<array32.length;i++){
??? var array32_TR=new Array();
???? array32_TR=array32[i];?
???? for(var j=0;j<array32_TR.length;j++){
????? //设置select的选中状态
?????? var select = document.getElementById(array32_TR[2]+"_select");
???????? for(var k=0;k<select.options.length;k++){
????????? if(select.options[k].value==array32_TR[0]){//数组的第一项都是选中状态
???? ??? select.options[k].selected=true;
????????? }
????????? if(arrayTR[0]=='show'){
????????? document.getElementById(array32_TR[2]+"_input").value=array32_TR[1];//设置input属性的值
????????? document.getElementById(array32_TR[2]+"_td").style.display='';//显示文本框
????????? }
??????? }
???? }
? }