Сообщение от Step48_rus
|
а что если мне нужно умножить 1000 полученную из '1_5': 1000,
на количество получанное из <input class="form-control" type="number" size="3" min="1" value="1" id="qty"> и записать в <div class="sum"></div>
|
https://www.youtube.com/watch?v=byuK7eVpx1Y
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<script src='https://code.jquery.com/jquery-latest.js'></script>
<!--
<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
-->
<style type='text/css'>
</style>
<script type='text/javascript'>
$(function(){
$('#mySelect, #mySelect2').change(test);
$('.form-control').on('input',test);
function test(){
var o={
'tipe1_mon1': 1000,
'tipe1_mon2': 2000,
'tipe2_mon1': 4000
};
var key=$('#mySelect > :checked').attr('id');
key+='_'+$('#mySelect2 > :checked').attr('id');
var val=o[key]? o[key]: '';
$('.price').text(val);
val*=$('.form-control').val();
$('.sum').text(val);
};
test();
});
</script>
</head>
<body>
<select id="mySelect">
<option value="1" id="tipe1">tipe1</option>
<option value="2" id="tipe2">tipe2</option>
<option value="3" id="tipe3">tipe3</option>
</select>
<select id="mySelect2">
<option value="5" id="mon1">mon1</option>
<option value="6" id="mon2">mon2</option>
<option value="7" id="mon3">mon3</option>
<option value="8" id="mon4">mon4</option>
</select>
<input class="form-control" type="number" size="3" min="1" value="1" id="qty" />
<div class="price"></div>
<div class="sum"></div>
</body>
</html>