2010-07-15 2 views

답변

1

다음 줄을 제거합니다

document.product.id_type.options[0] = new Option("[ Type ]"); 

    document.product.id_style.options[0] = new Option("[ Style ]"); 
+0

나는 노력하지만 비어있는 첫 번째 옵션이 표시됩니다 ... –

+1

첫 번째 자리에서 여전히 빈 행을 예약합니다. 첫 번째 옵션을 완전히 없애기 위해 inorder를 사용하여 i = 0을 시작하고 [i-1]에서 [i]와 같은 다른 코딩을 조정합니다. – Ifi

+0

잘 작동합니다. 감사합니다! –

0

이미 코드에 약간의 미 조정을 제안 것뿐만 아니라, 설정 = 0 1, 당신은 또한 두 번째 콤보 사용 J = 0에서 비어있는 첫 번째 옵션을 제거하려면

================================

function init(sel_type, sel_style){ 
    for(i = 0; i <= TypeArray.length; i++){ 
     document.product.id_type.options[i] = new Option(TypeArray[i].type, TypeArray[i].id); 

     if(TypeArray[i].id == sel_type) 
      document.product.id_type.options[i].selected = true; 
    } 

    OnChange(sel_style); 
} 


function OnChange(sel_style){ 
    sel_type_index = document.product.id_type.selectedIndex; 
    sel_type_value = parseInt(document.product.id_type[sel_type_index].value); 
    for(i = document.product.id_style.length - 1; i > 0; i--) 
     document.product.id_style.options[i] = null; 
    j=1; 
    for(i = 0; i <= StyleArray.length; i++){ 
     if(StyleArray[i].id_type == sel_type_value){ 
      document.product.id_style.options[j] = new Option(StyleArray[i].style, StyleArray[i].id); 

      if(StyleArray[i].id == sel_style) document.product.id_style.options[j].selected = true; 

      j++; 
     } 

    } 
} 
관련 문제