<script>
$(document).ready(function() {
// fix dropdown width
$('select[name="Mindestlaufzeit"]').parents('div.dropdown-list').css('width','auto');
// get purchase pricing
var priceArr = $('select[name="Mindestlaufzeit"]').parents('table').find('tbody tr td:nth-child(2)').map(function(){return parseFloat($(this).text().replace('€','').trim());}).get();
$('select[name="Mindestlaufzeit"]').change(
function() {
let min_duration = $(this).val();
let index = $('select[name="Mindestlaufzeit"]').prop('selectedIndex');
let tds = $(this).parents('table').find('tbody tr td:nth-child(3)');
tds.each(
function(tdIndex) {
let price = priceArr[tdIndex] / (parseInt(min_duration, 10) + (12 + index));
if (price <= 7) { price = 7; };
let priceTag = Number(price)
$(this).text(priceTag.toFixed(2).replace('.',',') + " €");
}
);
}
);
});
</script> |