2010-04-25 1 views
1

Je rencontre des problèmes lors de la mise à jour du contenu d'un div dans IE à l'aide de .update; J'ai aussi essayé avec innerHTML sans succès. Mon script fonctionne bien avec firefox et chrome, mais je dois le faire fonctionner avec IE (ni 7 ni 8 n'acceptent les fonctions). Des indices? Merci d'avance.La mise à jour de Prototype ne fonctionne pas avec IE

Le contexte est un panier simple avec deux boutons rotatifs pour modifier la quantité d'article à acheter. Voici le code:

<!-- 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

Tout code pour montrer? –

Répondre

0

pas eu assez de temps pour regarder en ce moment, changer votre code à ce fait fonctionner si:

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

J'ai mis à jour la question avec le code correspondant. – xain

Questions connexes