Показать сообщение отдельно
  #8 (permalink)  
Старый 26.03.2014, 12:44
Аспирант
Отправить личное сообщение для Officeoff.ru Посмотреть профиль Найти все сообщения от Officeoff.ru
 
Регистрация: 14.03.2014
Сообщений: 64

Сообщение от рони Посмотреть сообщение
а у нас было )))

и вариант для медитации
http://javascript.ru/forum/dom-window/45148-kak-sdelat-takojj-kalkulyator-pri-uslovii-chto-tovarov-mozhet-byt-80-100-a.html#post298023
Не понимаю я!
<html>
<head>
<script  type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
	$('.str').on("keyup",".quantity, .price, .discount, .sum" ,function(){
		var o=$(this.parentNode.parentNode);
		var kol = o.find('.quantity').val();
		var price = o.find('.price').val();
		var discount = o.find('.discount').val();
		var result = kol * price;
			if (discount.length>0){
				var discount = result / 100 * discount;
				var result = result - discount;
			}
		if (!isNaN(result)) {
			var result = Math.floor(result*100)/100
			o.find('.sum').val(result);
		}
		$(".sum").each( function () {
		allsum += parseInt( $(this).text(), 10 );
		});
		alert(allsum);
	});
});
</script>
</head>
<body><table class='table'>
<tr class='str'><td><input name='quantity' class='quantity' type='text'></td><td><input name='price' class='price' type='text'></td><td><input name='discount' class='discount' type='text'></td><td><input name='sum' class='sum' type='text'></td></tr>
<tr class='str'><td><input name='quantity' class='quantity' type='text'></td><td><input name='price' class='price' type='text'></td><td><input name='discount' class='discount' type='text'></td><td><input name='sum' class='sum' type='text'></td></tr>
<tr class='str'><td><input name='quantity' class='quantity' type='text'></td><td><input name='price' class='price' type='text'></td><td><input name='discount' class='discount' type='text'></td><td><input name='sum' class='sum' type='text'></td></tr>
<tr class='str'><td colspan='3'></td><td><input class='allsum' type='text'></td></tr>
</table>
</body>
</html>

Написал такую фигню. В итоге allsum = NaN
Ответить с цитированием