Tell me how to display a variable not in span, but in input with this code.
$(function(){
$('#main input:radio').on("change", function(){
var summ = 18900;
$('#main input:radio:checked').each(function(index, element){
var add = parseInt($(element).val(), 10);
if(!isNaN(add))
summ += add;
});
$("#result span").text(summ);
})
})
<div class="result d-flex justify-content-center md-auto" id="result">
<span>18900</span> руб.
<input type="text" id="result" value="18900">
</div>
Your input should be the only element with the 'result' value in it's id property.
If you will do so, you will be able to use js document.getElementById('result') to get the input element, and then set it's 'value' property
(e.g. document.getElementById('result').value = sum;)
You can also use jQuery format
(e.g. $('#result').val(sum);)