2010-04-25 5 views
1

.update를 사용하여 IE에서 div의 컨텐츠를 업데이트하는 데 문제가 있습니다. 나는 또한 성공없이 innerHTML로 시도했다. 내 스크립트는 파이어 폭스와 크롬으로 잘 작동하지만, IE에서도 작동하도록해야한다 (7이나 8은 함수를 받아들이지 않는다). 어떤 힌트? 미리 감사드립니다. Prototype의 업데이트가 IE와 작동하지 않습니다.

컨텍스트 구입 할 수있는 항목의 수량을 수정하는 두 개의 회 전자 버튼을 사용하여 간단한 쇼핑 카트입니다. 여기 코드는 다음과 같습니다

<!-- the input (quantity) --> 
<input type="text" class="cant" id="m__1" value="0" 
    size="2" readonly/> 
<!-- the price associated with the input --> 
<input type="hidden" id="h__1" name="h__1" value="100"/> 
<!-- the "addition" spinner button for the quantity --> 
<input type=button value=" + " onclick="$('m__1').value++;recalc();" 
    style="font-size:11px;margin:0;padding:0;width:20px;height:19px;" > 

<!-- the js function --> 
function recalc() { 

    total = 0 
    $$('input.cant').each(function(field) { 
    var idprice = 'h__' + field.id.substr(3) 
    var price = parseFloat($F(idprice)) 
    var quant = parseInt(field.value) 

    total += (quant * price) 
    }); 
    $('totcart').innerHTML='Total ' + total 
    return total 
} 

<!-- the div --> 
<div align="right" id="totcart"></div> 
+0

코드 보여? –

답변

0

충분한 시간이 그것이 비록 작동하게하는 코드를 변경, 지금보고 없어 :

function recalc() { 
    total = 0 
    $$('input.cant').each(function(field) { 
    var idprice = 'h__' + field.id.substr(3) 
    var price = parseFloat($F(idprice)) 
    var quant = parseInt(field.value) 
    total += (quant * price) 
    }); 
    $('totcart').innerHTML='Total ' + total 
    return total 
} 
document.observe("dom:loaded",function(){ 
    $('changer').observe("click",function(){ 
     $('m__1').value++; 
     recalc(); 
    });  
}); 


<!-- the input (quantity) --> 
<input type="text" class="cant" id="m__1" value="0" size="2" readonly/> 
<!-- the price associated with the input --> 
<input type="hidden" id="h__1" name="h__1" value="100"/> 
<!-- the "addition" spinner button for the quantity --> 
<input type=button value=" + " id="changer" style="font-size:11px;margin:0;padding:0;width:20px;height:19px;" > 
<!-- the div --> 
<div align="right" id="totcart"></div> 
+0

해당 코드로 질문을 업데이트했습니다. – xain

관련 문제