2011-05-06 3 views
0

이 코드에 어떤 문제가 있습니까? 정의되지 않은 오류가 발생합니다. 내 체크 박스는 다른 이름을 사용하고 난 사용자가 하나 개의 체크 박스를 선택합니다 프런트 엔드에 배열되지 않습니다 : ......해당 값을 할당 할 동적 체크 박스 이름

function select_item(index){ 
    var choice_options = []; 
    choice_options['S'] = 'item_cb_S'; 
    choice_options['T'] = 'item_cb_T'; 
    choice_options['Z'] = 'item_cb_Z'; 
    choice_options['D'] = 'item_cb_D'; 
    choice_options['N'] = 'item_cb_N'; 


    for (i in choice_options) { 
     var vl = choice_options[i]; 

     if(vl.substring(8) == index) { 
      document.wizardform.choice_options[index].checked = true;  
      //alert("true"); 
     } 
     else { 
     document.wizardform.vl.checked = false; 
     } 
    } 
    return true; 
} 

답변

0

그것은 너무 꽤 아니지만 당신이 평가 후면 사용할 수를

function select_item(index){ 
    var choice_options = []; 
    choice_options['S'] = 'item_cb_S'; 
    choice_options['T'] = 'item_cb_T'; 
    choice_options['Z'] = 'item_cb_Z'; 
    choice_options['D'] = 'item_cb_D'; 
    choice_options['N'] = 'item_cb_N'; 


    for (i in choice_options) { 
     var vl = choice_options[i]; 

     if(vl.substring(8) == index) { 
      eval("document.wizardform." + choice_options[index] + ".checked = true;"); 
      //alert("true"); 
     } 
     else { 
     document.wizardform.vl.checked = false; 
     } 
    } 
    return true; 
} 
관련 문제