Page tree
No Translation available yet

You have English selected as language but this page has not been translated yet. Translate the page or view the content in the default space language below.

Display default

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HTML
<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.prop('selectedIndex', 2);
   dropdown.change(); // calculate on load
});
</script>