title: Cannot read property 'toFixed' of undefined (Corrected)
body: <p>I've been looking at the code and breaking it apart but I can't seem to find what's causing the error.  I'm not sure what I'm doing wrong with the .toFixed that's breaking the code.  Can you help?</p>
  
  <p>Code (corrected)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function(){
          function getTotal() {
              var quantity =  $('#tmp_quantity').val();
              var name = "formComponentsMap['order'].countryName";
              var countryValue = $('input[name="' + name + '"]').val(); 
              var tax = 0.00;
              var shipping = 0.00;
  
              var stateName = "formComponentsMap['order'].stateId";
              var stateValue = $('select[name="' + stateName + '"]').val(); 
              // If state value is Maryland (33) need to add 6% sales tax
              if (stateValue == 33) {
                  tax = .06;  
              }
  
              if ($('#ADS_INTL').is(':checked') || $('#ADS_US').is(':checked')) {
  
                  if ($('#ADS_INTL').is(':checked') &amp;&amp; quantity == 1) {
                      shipping = 14.95;
                      var ads = '';
                  }
                  else {
  
                      shipping = 0.00;
                      var ads = '&lt;span style="color: #A3BF3F;"&gt;&amp;#x2714;&lt;/span&gt; with Auto-Delivery Service';
                  }
              }
              else {
                  var ads = '';
                  if (countryValue != "UNITED STATES" || typeof countryValue == 'undefined') {
                      shipping = 14.95;
                  }
                  else {
                    shipping = 6.95;  
                  }
              }
              var subtotal = 0.00;
              $('#quantity').replaceWith('&lt;div id="quantity"&gt;' + quantity + '&lt;/div&gt;');
              if (quantity == 6) {
                  $('#bottle-image').replaceWith('&lt;div id="bottle-image"&gt; &lt;img src="https://nmhfiles.com/images/nsn/650SSO2_FPOF/Soothanol-6Bottles.jpg" alt="Soothanol" width="150" /&gt;&lt;/div&gt;');
                  subtotal = 149.85;
              }
  
              else if (quantity == 3) {
                  $('#bottle-image').replaceWith('&lt;div id="bottle-image"&gt; &lt;img src="https://nmhfiles.com/images/nsn/650SSO2_FPOF/Soothanol-3Bottles.jpg" alt="Soothanol" width="150" /&gt;&lt;/div&gt;');
                  subtotal = 99.90;
              }
              else if (quantity == 1) {
                  $('#bottle-image').replaceWith('&lt;div id="bottle-image"&gt; &lt;img src="https://nmhfiles.com/images/nsn/650SSO2_FPOF/Soothanol-1Bottle.jpg" alt="Soothanol" width="150" /&gt;&lt;/div&gt;');
                  subtotal = 49.95;
              }
              $('#ads').replaceWith('&lt;div id="ads"&gt;' + ads + '&lt;/div&gt;');     
              $('#subtotal').replaceWith('&lt;div id="subtotal"&gt;' + subtotal.toFixed(2) + '&lt;/div&gt;');               
              $('#tax').replaceWith('&lt;div id="tax"&gt;' + (tax * subtotal).toFixed(2) + '&lt;/div&gt;');
              $('#shipping').replaceWith('&lt;div id="shipping"&gt;' + shipping.toFixed(2) + '&lt;/div&gt;');
              var total = subtotal + (tax * subtotal) + shipping;
              $('#total').replaceWith('&lt;div id="total"&gt;' + total.toFixed(2) + '&lt;/div&gt;');        
          }
  
          $("div[class^='tim']").click(function(){
                   var radioValue = $(this).attr('id');
  
                   if (typeof radioValue != "undefined") {
  
                   var quantity = radioValue.split('_timSelect_'); 
                    $('#tmp_quantity').val(quantity[1]);
                    var quantity =  $('#tmp_quantity').val();
                    getTotal();
                    }
              });  
  
          $('#__billToZipCode').click(function(){
              getTotal();     
          });
          $('#ADS_US').click(function(){
              getTotal();     
          });     
          $('#ADS_INTL').click(function(){
              getTotal();     
          });     
  
      });
  &lt;/script&gt;
  </code></pre>