- /*
- This source is shared under the terms of LGPL 3
- www.gnu.org/licenses/lgpl.html
- You are free to use the code in Commercial or non-commercial projects
- */
- //Set up an associative array
- //The keys represent the binding
- var binding_prices = new Array();
- binding_prices["hardcover"]=5;
- binding_prices["softcover"]=4;
- binding_prices["brochure"]=3;
- binding_prices["sbinding"]=2;
- //Set up an associative array
- //The keys represent the pages
- var pages_prices= new Array();
- pages_prices["25pages"]=0;
- pages_prices["50pages"]=5;
- pages_prices["75pages"]=5;
- pages_prices["100pages"]=7;
- pages_prices["125pages"]=8;
- pages_prices["150pages"]=10;
- pages_prices["175pages"]=5;
- pages_prices["200pages"]=9;
- pages_prices["225pages"]=5;
- pages_prices["250pages"]=5;
- pages_prices["275pages"]=8;
- pages_prices["300pages"]=7;
- //Set up an associative array
- //The keys represent the pages
- var quantity_prices= new Array();
- quantity_prices["30pcs"]=8;
- quantity_prices["50pcs"]=7;
- quantity_prices["100pcs"]=5;
- quantity_prices["200pcs"]=3;
- quantity_prices["300pcs"]=0;
- function getBindingPrice()
- {
- var bindingPrice=0;
- //Get a reference to the form id="choice_books"
- var theForm = document.forms["choice_books"];
- //Get a reference to the select id="binding"
- var selectedBinding = theForm.elements["binding"];
- bindingPrice = binding_prices[selectedBinding.value];
- return bindingPrice;
- }
- function getPagesPrice()
- {
- var pagesPrice=0;
- //Get a reference to the form id="choice_books"
- var theForm = document.forms["choice_books"];
- //Get a reference to the select id="binding"
- var selectedPages = theForm.elements["pages"];
- pagesPrice = pages_prices[selectedPages.value];
- return pagesPrice;
- }
- function getQuantityPrice()
- {
- var quantityPrice=0;
- //Get a reference to the form id="choice_books"
- var theForm = document.forms["choice_books"];
- //Get a reference to the select id="binding"
- var selectedQuantity = theForm.elements["quantity"];
- quantityPrice = quantity_prices[selectedQuantity.value];
- return quantityPrice;
- }
- function calculateTotal()
- {
- //Here we get the total price by calling our function
- //Each function returns a number so by calling them we add the values they return together
- var bookPrice = getBindingPrice() + getPagesPrice() + getQuantityPrice();
- //display the result
- var divobj = document.getElementById('totalPrice');
- divobj.style.display='block';
- divobj.innerHTML = "Gesamtpreis €"+cakePrice;
- }
- function hideTotal()
- {
- var divobj = document.getElementById('totalPrice');
- divobj.style.display='none';
- }