Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.
HTML-Format
<script>
$(document).ready(function() {
   // fix dropdown width
   var dropdown = $('select[name="Mindestlaufzeit"]');
   dropdown.parents('div.dropdown-list').css('width','auto');
   // get purchase pricing
   var priceArr = dropdown.parents('table').find('tbody tr td:nth-child(2)').map(function(){return parseFloat($(this).text().replace(/[€\.\s]/g,'').trim());}).get();
   dropdown.change(
		function() {
			let min_duration = $(this).val();
			let index = dropdown.prop('selectedIndex');
			let tds = $(this).parents('table').find('tbody tr td:nth-child(3)');
			tds.each(
				function(tdIndex) {
					let purchasePrice = priceArr[tdIndex];
					//let price = priceArr[tdIndex] / ((parseInt(min_duration, 10)/1.75) + (12 + index));
					let price = purchasePrice / ((parseInt(min_duration, 10)/1.75) + ((16 + index) - Math.sqrt(min_duration)));
					if (price <= 7) { price = 7; };
					let priceTag = Number(price)
					$(this).text(priceTag.toFixed(2).replace('.',',') + " €");
				}
			);
		}
   );
   dropdown.change(); // calculate on load
});
</script>