Обновление прототипа не работает с IE - PullRequest
1 голос
/ 25 апреля 2010

У меня проблемы с обновлением содержимого div в IE с использованием .update; Я также попробовал с innerHTML безуспешно. Мой скрипт отлично работает с Firefox и Chrome, но мне нужно, чтобы он тоже работал с IE (ни 7, ни 8 не принимают функции). Есть намеки? Заранее спасибо.

Контекст представляет собой простую корзину для покупок с двумя вращающимися кнопками для изменения количества покупаемого товара. Вот код:

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

1 Ответ

0 голосов
/ 25 апреля 2010

не хватает времени, чтобы посмотреть прямо сейчас, хотя изменение кода заставляет его работать:

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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...