
merhabalar şu şekilde bir formum var benim yapmak istediğim ise şu
2016 yı seçince yanındaki inputa 10 değerini yazması
2015 i seçince 5 değeri yazıp 10 rakamının üzerine toplaması ve sonuç olarak 15 yazması
bunu nasıl yapabilirim ?
12
●1.172

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<form method="post">
<select id="years" name="years" multiple>
<option value="10">2016</option>
<option value="5">2015</option>
</select>
<input type="text" id="total" name="total" />
</form>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript">
function is_numeric(input) {
return (input - 0) == input && (input+'').replace(/^\s+|\s+$/g, "").length > 0;
}
$(function() {
$("select#years").change(function() {
var input = $("input#total");
input.val(Number(input.val()) + Number($(this).val()));
});
});
</script>
</body>
</html> <select multiple="multiple" name="price[]" id="sel_1">
<option value="0"></option>
<option value="10">2015</option>
<option value="15">2016</option>
</select>
<span id="usertotal"> </span>var $total = $('#usertotal');
$('input,select').change(function () {
var tot = 0;
$('input:checkbox:checked, select > option:selected').each(function () {
var per_op = $(this).attr('value');
if (per_op) {
tot += Number(per_op);
}
});
var final_result = tot.toFixed(2);
$total.html(final_result)
});Demo <select name="renk[]" multiple="renk[]">
<option selected value="0">Seçiniz..</option>
<option value="48">2013</option>
<option value="48">2012</option>
<option value="48">2011</option>
<option value="48">2010</option>
<option value="36">2009</option>
<option value="36">2008</option>
<option value="36">2007</option>
<option value="18">2006</option>
<option value="18">2005</option>
</select>
<input name="usertotal" />
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript">
var $total = $('#usertotal');
$('input,select').change(function () {
var tot = 0;
$('input:checkbox:checked, select > option:selected').each(function () {
var per_op = $(this).attr('value');
if (per_op) {
tot += Number(per_op);
}
});
var final_result = tot.toFixed(2);
$total.html(final_result)
$('input[name="usertotal"]').val(final_result);
});
</script>