二级联动之二

<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --> var  firstStage  =  [
    {value:
" 点击这里 " ,text: " 点击这里 " },
    {value:
" 个性化 " ,text: " 个性化 " },
    {value:
" 转发 " ,text: " 转发 " },
    {value:
" 退订 " ,text: " 退订 " }];
    
var  secondStage  =  [
    {value:
" 点击这里 " ,text:  " 点击这里 " , refValue :  " 点击这里 " },
    {value:
" #firstName# " ,text: " " , refValue :  " 个性化 " },
    {value:
" #lastName# " ,text: " " , refValue :  " 个性化 " },
    {value:
" #sex# " ,text: " 性别 " , refValue :  " 个性化 " },
    {value:
" #email# " ,text: " Email " , refValue :  " 个性化 " },
    {value:
" #content1# " ,text: " content1 " , refValue :  " 个性化 " },
    {value:
" #content2# " ,text: " content2 " , refValue :  " 个性化 " },
    {value:
" #content3# " ,text: " content3 " , refValue :  " 个性化 " },
    {value:
" 转发 " ,text: " 转发 " , refValue :  " 转发 " },
    {value:
" 退订 " ,text: " 退订 " , refValue :  " 退订 " }];
    
function  __initSel(oKeyValues, oSel, initValue) {
    oSel.length 
=   0 ;
    
var  oPrompt  =  {value: "" ,text: " 请选择 " };
    oKeyValues.unshift(oPrompt);
    
for ( var  i = 0 ;i < oKeyValues.length; i = i + 1 )
    {
        
var  oKeyValue  =  oKeyValues[i];
        
var   oOption  =  document.createElement( " option " );
        oOption.value 
=  oKeyValue.value;
        
if (oKeyValue.value  ==  initValue)
        {
            oOption.selected 
=   true ;
        }
        
var  oText  =  document.createTextNode(oKeyValue.text);
        oOption.appendChild(oText);
        oSel.appendChild(oOption);
    }
}

function  initFirstStageSel(firstStageSelId, initValue)
{
    
var  oSel  =  document.getElementById(firstStageSelId);
    __initSel(firstStage, oSel, initValue);
}

function  initSecondStageSel(firstStageSelId,secondStageSelId,initValue)
{
    
var  oSelFirstStage  =  document.getElementById(firstStageSelId);
    
var  oSelSecondStage  =  document.getElementById(secondStageSelId);
    
var  aTempKeyValus  =   new  Array();
    
for ( var  i = 0 ;i < secondStage.length;i = i + 1 )
    {
        
if (secondStage[i].refValue  ==  oSelFirstStage.value)
        {
            aTempKeyValus.push(secondStage[i]);
        }
    }
    __initSel(aTempKeyValus, oSelSecondStage, initValue);
}

你可能感兴趣的:(级联)