troubleshooting Question

Add a Location and Color Price based on select box selected option

Avatar of niceoneishere
niceoneishere asked on
JavaScriptHTMLjQuery
17 Comments2 Solutions238 ViewsLast Modified:
I have a price calculator which calculates the price of shirts based on quantity entered and design location and colors.

I got the quantity part calculating correctly based on the number of units entered per size. But location and design is where I am getting stuck.

There are basically 4 max locations a shirt design can have and each location can have 4 max colors.

The base price per unit includes the first location and first color and from then no there is the price distribution

Locations:

1 location price is 0 as its included in the base price
2 locations price is extra dollar
3 locations price is extra 2 dollars
4 locations price is extra 3 dollars

Colors Per Location:

1 color price is 0 as its included in the base price
2 colors price is extra dollar
3 colors price is extra 2 dollars
4 colors price is extra 3 dollars

So far example, If an adult xs size shirt unit price is 7.66 and 15 units with one location and one color are selected then price will be 15 * 7.66 = 114.90

but for the same 15 units if 2 locations and 2 colors are selected then price should be (7.66 + 1 + 1) * 15 = 144.90.

And this where I am stuck. Here is my complete code I have so far in the link below and I am using pure JavaScript. Thanks and appreciate it

jFiddle

	<form id="quoteform" action="mail_quote.php" method="post">
  <div class="adult-sizes-box">
	<h2 class="section-title">1. Quantities and Sizes (A minimum total of 12 shirts is required.)</h2>
	<h3 class="small-title">Adult Sizes</h3>
	<div class="pc-row">
	<ul class="quote-sizes adult-sizes noul pc-col">
	  <li><label><span>Adult X Small</span><input id="adult_xs" type="text" name="adult_xs" data-var="adult_xs" class="amtbox" placeholder="quanity"  /></label></li>
	  <li><label><span>Adult Small</span><input id="adult_s" type="text" name="adult_s" data-var="adult_s" class="amtbox" placeholder="quanity" /></label></li>
	  <li><label><span>Adult Medium</span><input id="adult_m" type="text" name="adult_m" data-var="adult_m" class="amtbox" placeholder="quanity" /></label></li>
	  <li><label><span>Adult Large</span><input id="adult_l" type="text" name="adult_l" data-var="adult_l" class="amtbox" placeholder="quanity" /></label></li>
	  <li><label><span>Adult X Large</span><input id="adult_xl" type="text" name="adult_xl" data-var="adult_xl" class="amtbox" placeholder="quanity" /></label></li>
	  
	</ul>
   <ul class="quote-sizes adult-sizes noul pc-col">
	  <li><label><span>Adult 2X Large</span><input id="adult_2xl" type="text" name="adult_2xl" data-var="adult_2xl" class="amtbox" placeholder="quanity" /></label></li>
	  <li><label><span>Adult 3X Large</span><input id="adult_3xl" type="text" name="adult_3xl" data-var="adult_3xl" class="amtbox" placeholder="quanity" /></label></li>
	  <li><label><span>Adult 4X Large</span><input id="adult_4xl" type="text" name="adult_4xl" data-var="adult_4xl" class="amtbox" placeholder="quanity" /></label></li>
      <li><label><span>Adult 5X Large</span><input id="adult_5xl" type="text" name="adult_5xl" data-var="adult_5xl" class="amtbox" placeholder="quanity" /></label></li>
	</ul>	
	</div>
	<div class="clear"></div>
	<div class="adult-sizes-box">
	<h2 class="section-title">2. Design Location and Colors</h2>
	<div class="pc-row">
	<ul class="quote-sizes locations-colors noul pc-col post-96 quote-item type-quote-item status-publish has-post-thumbnail hentry barndoor-quotes-tee-shirts">
	 <li><label for="front_left_chest"><span>Front Left Chest</span>
	    <select name="front_left_chest" id="front_left_chest" onchange="getFrontLeftChestColor()">
         <option value="none">Number of Colors</option>
         <option value="one color">1 Color</option>
         <option value="two colors">2 Colors</option>
         <option value="three colors">3 Colors</option>
         <option value="four colors">4 Colors</option>
        </select></label>
	 </li>
	 	 <li><label><span>Full Chest</span>
	    <select name="full_chest" id="full_chest">
        <option value="none">Number of Colors</option>
         <option value="one color">1 Color</option>
         <option value="two colors">2 Colors</option>
         <option value="three colors">3 Colors</option>
         <option value="four colors">4 Colors</option>
        </select></label>
	 </li>
	<li><label><span>Left Sleeve</span>
	    <select name="left_sleeve" id="left_sleeve">
        <option value="none">Number of Colors</option>
         <option value="one color">1 Color</option>
         <option value="two colors">2 Colors</option>
         <option value="three colors">3 Colors</option>
         <option value="four colors">4 Colors</option>
        </select></label>
	 </li>
	</ul>
		<ul class="quote-sizes locations-colors noul pc-col post-96 quote-item type-quote-item status-publish has-post-thumbnail hentry barndoor-quotes-tee-shirts">
	 <li><label><span>Front Right Chest</span>
	    <select name="front_right_chest" id="front_right_chest" onchange="getFrontRightChestColor()">
         <option value="none">Number of Colors</option>
         <option value="one color">1 Color</option>
         <option value="two colors">2 Colors</option>
         <option value="three colors">3 Colors</option>
         <option value="four colors">4 Colors</option>
        </select></label>
	 </li>
	 	 <li><label><span>Full Back</span>
	    <select name="full_back" id="full_back">
        <option value="none">Number of Colors</option>
         <option value="one color">1 Color</option>
         <option value="two colors">2 Colors</option>
         <option value="three colors">3 Colors</option>
         <option value="four colors">4 Colors</option>
        </select></label>
	 </li>
	<li><label><span>Right Sleeve</span>
	    <select name="right_sleeve" id="right_sleeve">
        <option value="none">Number of Colors</option>
         <option value="one color">1 Color</option>
         <option value="two colors">2 Colors</option>
         <option value="three colors">3 Colors</option>
         <option value="four colors">4 Colors</option>
        </select></label>
	 </li>
	</ul>
	</div>
	</div>
	
	
<input id="adult_xsxl_price24" type="hidden" name="adult_xsxl_price24" value="7.66" />
<input id="adult_xsxl_price36" type="hidden" name="adult_xsxl_price36" value="6.66" />
<input id="adult_xsxl_price48" type="hidden" name="adult_xsxl_price48" value="6.29" />
<input id="adult_xsxl_price60" type="hidden" name="adult_xsxl_price60" value="5.94" />
<input id="adult_xsxl_price72" type="hidden" name="adult_xsxl_price72" value="5.65" />
<input id="adult_xsxl_price96" type="hidden" name="adult_xsxl_price96" value="5.38" />
<input id="adult_xsxl_price144" type="hidden" name="adult_xsxl_price144" value="4.98" />

	<div class="quote-total">
    <button type="button" id="get-quote" onclick="calculateTotal()">Get Quote Total </button>
	<h3 id="totalprice"> </h3>
	<div id="quote-details"></div>
	</div>
	</div>
  </form>

and JavaScript

// adult x-small qty and price
function getAdultXSQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_xs"];
var howmany_adult_xs =0;
if(quantity.value!=""){var howmany_adult_xs = parseInt(quantity.value);}
return howmany_adult_xs;
}
function getAdultXSPrice()
{
var adult_xs_qty =  getAdultXSQty();
var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value);
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value);
var price48 = parseFloat(theForm.elements["adult_xsxl_price48"].value);
var price60 = parseFloat(theForm.elements["adult_xsxl_price60"].value);
var price72 = parseFloat(theForm.elements["adult_xsxl_price72"].value);
var price96 = parseFloat(theForm.elements["adult_xsxl_price96"].value);
var price144 = parseFloat(theForm.elements["adult_xsxl_price144"].value);
if(adult_xs_qty <=24){
	var adult_xs_totprice = adult_xs_qty * price24;
}else if(adult_xs_qty > 24 && adult_xs_qty <=36){
		var adult_xs_totprice = adult_xs_qty * price36;
}else if(adult_xs_qty > 36 && adult_xs_qty <=48){
		var adult_xs_totprice = adult_xs_qty * price48;
}else if(adult_xs_qty > 48 && adult_xs_qty <=60){
		var adult_xs_totprice = adult_xs_qty * price60;
}else if(adult_xs_qty > 60 && adult_xs_qty <=72){
		var adult_xs_totprice = adult_xs_qty * price72;
}else if(adult_xs_qty > 72 && adult_xs_qty <=96){
		var adult_xs_totprice = adult_xs_qty * price96;
}else if(adult_xs_qty > 96 && adult_xs_qty <=144){
		var adult_xs_totprice = adult_xs_qty * price144;
}else{
		var adult_xs_totprice = adult_xs_qty * price144;
}
return adult_xs_totprice;
}

// adult small qty and price
function getAdultSQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_s"];
var howmany_adult_s =0;
if(quantity.value!=""){var howmany_adult_s = parseInt(quantity.value);}
return howmany_adult_s;
}
function getAdultSPrice()
{
var adult_s_qty =  getAdultSQty();
var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value);
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value);
var price48 = parseFloat(theForm.elements["adult_xsxl_price48"].value);
var price60 = parseFloat(theForm.elements["adult_xsxl_price60"].value);
var price72 = parseFloat(theForm.elements["adult_xsxl_price72"].value);
var price96 = parseFloat(theForm.elements["adult_xsxl_price96"].value);
var price144 = parseFloat(theForm.elements["adult_xsxl_price144"].value);
if(adult_s_qty <=24){
	var adult_s_totprice = adult_s_qty * price24;
}else if(adult_s_qty > 24 && adult_s_qty <=36){
		var adult_s_totprice = adult_s_qty * price36;
}else if(adult_s_qty > 36 && adult_s_qty <=48){
		var adult_s_totprice = adult_s_qty * price48;
}else if(adult_s_qty > 48 && adult_s_qty <=60){
		var adult_s_totprice = adult_s_qty * price60;
}else if(adult_s_qty > 60 && adult_s_qty <=72){
		var adult_s_totprice = adult_s_qty * price72;
}else if(adult_s_qty > 72 && adult_s_qty <=96){
		var adult_s_totprice = adult_s_qty * price96;
}else if(adult_s_qty > 96 && adult_s_qty <=144){
		var adult_s_totprice = adult_s_qty * price144;
}else{
		var adult_s_totprice = adult_s_qty * price144;
}
return adult_s_totprice;
}

// adult medium qty and price
function getAdultMQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_m"];
var howmany_adult_m =0;
if(quantity.value!=""){var howmany_adult_m = parseInt(quantity.value);}
return howmany_adult_m;
}
function getAdultMPrice()
{
var adult_m_qty =  getAdultMQty();

var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value);
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value);
var price48 = parseFloat(theForm.elements["adult_xsxl_price48"].value);
var price60 = parseFloat(theForm.elements["adult_xsxl_price60"].value);
var price72 = parseFloat(theForm.elements["adult_xsxl_price72"].value);
var price96 = parseFloat(theForm.elements["adult_xsxl_price96"].value);
var price144 = parseFloat(theForm.elements["adult_xsxl_price144"].value);
if(adult_m_qty <=24){
	var adult_m_totprice = adult_m_qty * price24;
}else if(adult_m_qty > 24 && adult_m_qty <=36){
		var adult_m_totprice = adult_m_qty * price36;
}else if(adult_m_qty > 36 && adult_m_qty <=48){
		var adult_m_totprice = adult_m_qty * price48;
}else if(adult_m_qty > 48 && adult_m_qty <=60){
		var adult_m_totprice = adult_m_qty * price60;
}else if(adult_m_qty > 60 && adult_m_qty <=72){
		var adult_m_totprice = adult_m_qty * price72;
}else if(adult_m_qty > 72 && adult_m_qty <=96){
		var adult_m_totprice = adult_m_qty * price96;
}else if(adult_m_qty > 96 && adult_m_qty <=144){
		var adult_m_totprice = adult_m_qty * price144;
}else{
		var adult_m_totprice = adult_m_qty * price144;
}
return adult_m_totprice;
}

// adult large qty and price
function getAdultLQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_l"];
var howmany_adult_l =0;
if(quantity.value!=""){var howmany_adult_l = parseInt(quantity.value);}
return howmany_adult_l;
}

function getAdultLPrice()
{
var adult_l_qty =  getAdultLQty();
var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value);
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value);
var price48 = parseFloat(theForm.elements["adult_xsxl_price48"].value);
var price60 = parseFloat(theForm.elements["adult_xsxl_price60"].value);
var price72 = parseFloat(theForm.elements["adult_xsxl_price72"].value);
var price96 = parseFloat(theForm.elements["adult_xsxl_price96"].value);
var price144 = parseFloat(theForm.elements["adult_xsxl_price144"].value);
if(adult_l_qty <=24){
	var adult_l_totprice = adult_l_qty * price24;
}else if(adult_l_qty > 24 && adult_l_qty <=36){
		var adult_l_totprice = adult_l_qty * price36;
}else if(adult_l_qty > 36 && adult_l_qty <=48){
		var adult_l_totprice = adult_l_qty * price48;
}else if(adult_l_qty > 48 && adult_l_qty <=60){
		var adult_l_totprice = adult_l_qty * price60;
}else if(adult_l_qty > 60 && adult_l_qty <=72){
		var adult_l_totprice = adult_l_qty * price72;
}else if(adult_l_qty > 72 && adult_l_qty <=96){
		var adult_l_totprice = adult_l_qty * price96;
}else if(adult_l_qty > 96 && adult_l_qty <=144){
		var adult_l_totprice = adult_l_qty * price144;
}else{
		var adult_l_totprice = adult_l_qty * price144;
}
return adult_l_totprice;
}

// adult x-large qty and price
function getAdultXLQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_xl"];
var howmany_adult_xl =0;
if(quantity.value!=""){var howmany_adult_xl = parseInt(quantity.value);}
return howmany_adult_xl;
}
function getAdultXLPrice()
{
var adult_xl_qty =  getAdultLQty();
var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value);
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value);
var price48 = parseFloat(theForm.elements["adult_xsxl_price48"].value);
var price60 = parseFloat(theForm.elements["adult_xsxl_price60"].value);
var price72 = parseFloat(theForm.elements["adult_xsxl_price72"].value);
var price96 = parseFloat(theForm.elements["adult_xsxl_price96"].value);
var price144 = parseFloat(theForm.elements["adult_xsxl_price144"].value);
if(adult_xl_qty <=24){
	var adult_xl_totprice = adult_xl_qty * price24;
}else if(adult_xl_qty > 24 && adult_xl_qty <=36){
		var adult_xl_totprice = adult_xl_qty * price36;
}else if(adult_xl_qty > 36 && adult_xl_qty <=48){
		var adult_xl_totprice = adult_xl_qty * price48;
}else if(adult_xl_qty > 48 && adult_xl_qty <=60){
		var adult_xl_totprice = adult_xl_qty * price60;
}else if(adult_xl_qty > 60 && adult_xl_qty <=72){
		var adult_xl_totprice = adult_xl_qty * price72;
}else if(adult_xl_qty > 72 && adult_xl_qty <=96){
		var adult_xl_totprice = adult_xl_qty * price96;
}else if(adult_xl_qty > 96 && adult_xl_qty <=144){
		var adult_xl_totprice = adult_xl_qty * price144;
}else{
		var adult_xl_totprice = adult_xl_qty * price144;
}
return adult_xl_totprice;
}

// adult 2xl qty and price
function getAdult2XLQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_2xl"];
var howmany_adult_2xl =0;
if(quantity.value!=""){var howmany_adult_2xl = parseInt(quantity.value);}
return howmany_adult_2xl;
}
function getAdult2XLPrice()
{
var adult_2xl_qty =  getAdult2XLQty();
var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value) +1;
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value) +1;
var price48 =  parseFloat(theForm.elements["adult_xsxl_price48"].value) +1;
var price60 =  parseFloat(theForm.elements["adult_xsxl_price60"].value) +1;
var price72 =  parseFloat(theForm.elements["adult_xsxl_price72"].value) +1;
var price96 =  parseFloat(theForm.elements["adult_xsxl_price96"].value) +1;
var price144 =  parseFloat(theForm.elements["adult_xsxl_price144"].value) +1;
if(adult_2xl_qty <=24){
	var adult_2xl_totprice = adult_2xl_qty * price24;
}else if(adult_2xl_qty > 24 && adult_2xl_qty <=36){
		var adult_2xl_totprice = adult_2xl_qty * price36;
}else if(adult_2xl_qty > 36 && adult_2xl_qty <=48){
		var adult_2xl_totprice = adult_2xl_qty * price48;
}else if(adult_2xl_qty > 48 && adult_2xl_qty <=60){
		var adult_2xl_totprice = adult_2xl_qty * price60;
}else if(adult_2xl_qty > 60 && adult_2xl_qty <=72){
		var adult_2xl_totprice = adult_2xl_qty * price72;
}else if(adult_2xl_qty > 72 && adult_2xl_qty <=96){
		var adult_2xl_totprice = adult_2xl_qty * price96;
}else if(adult_2xl_qty > 96 && adult_2xl_qty <=144){
		var adult_2xl_totprice = adult_2xl_qty * price144;
}else{
		var adult_2xl_totprice = adult_2xl_qty * price144;
}
return adult_2xl_totprice;
}

// adult 3xl qty and price
function getAdult3XLQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_3xl"];
var howmany_adult_3xl =0;
if(quantity.value!=""){var howmany_adult_3xl = parseInt(quantity.value);}
return howmany_adult_3xl;
}
function getAdult3XLPrice()
{
var adult_3xl_qty =  getAdult3XLQty();
var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value) + 2;
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value) + 2;
var price48 =  parseFloat(theForm.elements["adult_xsxl_price48"].value) + 2;
var price60 =  parseFloat(theForm.elements["adult_xsxl_price60"].value) + 2;
var price72 =  parseFloat(theForm.elements["adult_xsxl_price72"].value) + 2;
var price96 =  parseFloat(theForm.elements["adult_xsxl_price96"].value) + 2;
var price144 =  parseFloat(theForm.elements["adult_xsxl_price144"].value) + 2;
if(adult_3xl_qty <=24){
	var adult_3xl_totprice = adult_3xl_qty * price24;
}else if(adult_3xl_qty > 24 && adult_3xl_qty <=36){
		var adult_3xl_totprice = adult_3xl_qty * price36;
}else if(adult_3xl_qty > 36 && adult_3xl_qty <=48){
		var adult_3xl_totprice = adult_3xl_qty * price48;
}else if(adult_3xl_qty > 48 && adult_3xl_qty <=60){
		var adult_3xl_totprice = adult_3xl_qty * price60;
}else if(adult_3xl_qty > 60 && adult_3xl_qty <=72){
		var adult_3xl_totprice = adult_3xl_qty * price72;
}else if(adult_3xl_qty > 72 && adult_3xl_qty <=96){
		var adult_3xl_totprice = adult_3xl_qty * price96;
}else if(adult_3xl_qty > 96 && adult_3xl_qty <=144){
		var adult_3xl_totprice = adult_3xl_qty * price144;
}else{
		var adult_3xl_totprice = adult_3xl_qty * price144;
}
return adult_3xl_totprice;
}

// adult 4xl qty and price
function getAdult4XLQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_4xl"];
var howmany_adult_4xl =0;
if(quantity.value!=""){var howmany_adult_4xl = parseInt(quantity.value);}
return howmany_adult_4xl;
}
function getAdult4XLPrice()
{
var adult_4xl_qty =  getAdult4XLQty();
var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value) + 3;
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value) + 3;
var price48 =  parseFloat(theForm.elements["adult_xsxl_price48"].value) + 3;
var price60 =  parseFloat(theForm.elements["adult_xsxl_price60"].value) + 3;
var price72 =  parseFloat(theForm.elements["adult_xsxl_price72"].value) + 3;
var price96 =  parseFloat(theForm.elements["adult_xsxl_price96"].value) + 3;
var price144 =  parseFloat(theForm.elements["adult_xsxl_price144"].value) + 3;
if(adult_4xl_qty <=24){
	var adult_4xl_totprice = adult_4xl_qty * price24;
}else if(adult_4xl_qty > 24 && adult_4xl_qty <=36){
		var adult_4xl_totprice = adult_4xl_qty * price36;
}else if(adult_4xl_qty > 36 && adult_4xl_qty <=48){
		var adult_4xl_totprice = adult_4xl_qty * price48;
}else if(adult_4xl_qty > 48 && adult_4xl_qty <=60){
		var adult_4xl_totprice = adult_4xl_qty * price60;
}else if(adult_4xl_qty > 60 && adult_4xl_qty <=72){
		var adult_4xl_totprice = adult_4xl_qty * price72;
}else if(adult_4xl_qty > 72 && adult_4xl_qty <=96){
		var adult_4xl_totprice = adult_4xl_qty * price96;
}else if(adult_4xl_qty > 96 && adult_4xl_qty <=144){
		var adult_4xl_totprice = adult_4xl_qty * price144;
}else{
		var adult_4xl_totprice = adult_4xl_qty * price144;
}
return adult_4xl_totprice;
}

// adult 5xl qty and price
function getAdult5XLQty()
{
var theForm = document.forms["quoteform"];
var quantity = theForm.elements["adult_5xl"];
var howmany_adult_5xl =0;
if(quantity.value!=""){var howmany_adult_5xl = parseInt(quantity.value);}
return howmany_adult_5xl;
}
function getAdult5XLPrice()
{
var adult_5xl_qty =  getAdult5XLQty();
var theForm = document.forms["quoteform"];
var price24 = parseFloat(theForm.elements["adult_xsxl_price24"].value) + 4;
var price36 = parseFloat(theForm.elements["adult_xsxl_price36"].value) + 4;
var price48 =  parseFloat(theForm.elements["adult_xsxl_price48"].value) + 4;
var price60 =  parseFloat(theForm.elements["adult_xsxl_price60"].value) + 4;
var price72 =  parseFloat(theForm.elements["adult_xsxl_price72"].value) + 4;
var price96 =  parseFloat(theForm.elements["adult_xsxl_price96"].value) + 4;
var price144 =  parseFloat(theForm.elements["adult_xsxl_price144"].value) + 4;
if(adult_5xl_qty <=24){
	var adult_5xl_totprice = adult_5xl_qty * price24;
}else if(adult_5xl_qty > 24 && adult_5xl_qty <=36){
		var adult_5xl_totprice = adult_5xl_qty * price36;
}else if(adult_5xl_qty > 36 && adult_5xl_qty <=48){
		var adult_5xl_totprice = adult_5xl_qty * price48;
}else if(adult_5xl_qty > 48 && adult_5xl_qty <=60){
		var adult_5xl_totprice = adult_5xl_qty * price60;
}else if(adult_5xl_qty > 60 && adult_5xl_qty <=72){
		var adult_5xl_totprice = adult_5xl_qty * price72;
}else if(adult_5xl_qty > 72 && adult_5xl_qty <=96){
		var adult_5xl_totprice = adult_5xl_qty * price96;
}else if(adult_5xl_qty > 96 && adult_5xl_qty <=144){
		var adult_5xl_totprice = adult_5xl_qty * price144;
}else{
		var adult_5xl_totprice = adult_5xl_qty * price144;
}
return adult_5xl_totprice;
}



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 totalqty = getAdultXSQty() + getAdultSQty() + getAdultMQty() + getAdultLQty() + getAdultXLQty() + getAdult2XLQty() + getAdult3XLQty() + getAdult4XLQty() + getAdult5XLQty();
	var qtymsg; var totprice = document.getElementById('totalprice'); var qdetails = document.getElementById('quote-details');
	if(totalqty < 12){	
	     totprice.style.display='none';	qdetails.style.display='none';
		 alert("You must order at least 12 shirts.");
		 
	}else{
		   var quoteprice = (getAdultXSPrice() + getAdultSPrice() + getAdultMPrice() + getAdultLPrice() + getAdultXLPrice() + getAdult2XLPrice() + getAdult3XLPrice() + getAdult4XLPrice() + getAdult5XLPrice()).toFixed(2);
            var perpiece = parseFloat(quoteprice/totalqty);
			totprice.style.display='block';qdetails.style.display='block';
            totprice.innerHTML = "Total quantity "+totalqty + " - Total Price $"+quoteprice;
			qdetails.innerHTML = "Cost per Piece: $"+perpiece.toFixed(2);
	        document.getElementById('totalquoteprice').value = quoteprice;
	
    }	
	
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros