www.webdeveloper.com
Results 1 to 4 of 4

Thread: JS quote calculator rounded to two decimal places

  1. #1
    Join Date
    May 2011
    Posts
    7

    JS quote calculator rounded to two decimal places

    Need help rounding the quote up to two decimal places. I've seen a lot of codes and tried a bunch (math.round, tofixed, toprecision) but not exactly sure how to use them and where to put them.

    Calculator can be viewed here along with the code
    http://nuinnovisions.com/shutterquotecalculator.html

    Code won't fit, I'll put it in a comment.

    Thanks,
    Melissa

  2. #2
    Join Date
    May 2011
    Posts
    7

    Code

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Shutter Quote Calculator</title>
    
    <script LANGUAGE="JavaScript1.2"><!--
     
    function CLcalc()
     
    {		
     
    
    
    var ClosedLouverPairPrice = 24.00
    
    var priming = document.ClosedLouverCalc.priming.value;
    
    var fauxtiltrods = document.ClosedLouverCalc.fauxtiltrods.value;
     
    var coppercaps = document.ClosedLouverCalc.coppercaps.value;
    
    var horns = document.ClosedLouverCalc.horns.value;
    
    var arches = document.ClosedLouverCalc.arches.value;
    
    var width = document.ClosedLouverCalc.width.value;
    
    var widthincrements = document.ClosedLouverCalc.widthincrements.value;
     
    var height =  document.ClosedLouverCalc.height.value;
    
    var heightincrements = document.ClosedLouverCalc.heightincrements.value;
    
    var quantity =  document.ClosedLouverCalc.quantity.value;
     
    var CostClosedLouverPair = priming + fauxtiltrods + coppercaps + horns + arches + (width + widthincrements) * (height + heightincrements) * 2 / 144 * ClosedLouverPairPrice;
    
    var CostClosedLouverTotal = priming + fauxtiltrods + coppercaps + horns + arches + (width + widthincrements) * (height + heightincrements) * 2 / 144 * ClosedLouverPairPrice * quantity;
     
     
     
     
     
     
    document.ClosedLouverCalc.CostClosedLouverPair.value = Math.abs(Math.abs(priming) + Math.abs(fauxtiltrods) + Math.abs(coppercaps) + Math.abs(horns) + Math.abs(arches) + (Math.abs(width) + Math.abs(widthincrements)) * (Math.abs(height) + Math.abs(heightincrements)) * 2 / 144 * ClosedLouverPairPrice);
    
    
    document.ClosedLouverCalc.CostClosedLouverTotal.value = Math.abs(Math.abs(priming) + Math.abs(fauxtiltrods) + Math.abs(coppercaps) + Math.abs(horns) + Math.abs(arches) + (Math.abs(width) + Math.abs(widthincrements)) * (Math.abs(height) + Math.abs(heightincrements)) * 2 / 144 * ClosedLouverPairPrice) * Math.floor(quantity);
     
     
     
     
     
    }
     
     
     
    // -->
     
    </script>
    </head>

  3. #3
    Join Date
    May 2011
    Posts
    7

    code pt 2

    Code:
    <body>
    <a href="shutterquotecalculatorcode.html" target="_blank">View code</a>
    <form NAME="ClosedLouverCalc" method="post" enctype="text">
    <label><br />
    </label>
    <div align="center">
      <table width="80%" border="1" cellpadding="5" cellspacing="0" bordercolor="#000000">
        <tr>
          <td>Closed Louver Style<br />
            Quote &amp; Order</td>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td><strong>Mid Rail Divider</strong><br />
          <select name="midraildivider" id="Mid Rail Divider">
            <option selected="selected">Select One</option>
            <option>None - 1 Panel</option>
            <option>50/50 - 2 Panel</option>
            <option>60/40 - Larger Top Panel</option>
            <option>40/60 - Larger Bottom Panel</option>
            <option>33/33/33 - 3 Panel</option>
          </select></td>
            </tr>
            <tr>
              <td><strong>Material</strong><br />
          <select name="material" id="material">
            <option selected="selected">Select One</option>
            <option>Western Red Cedar</option>
          </select></td>
            </tr>
            <tr>
              <td><strong>Thickness</strong><br />
          <select name="thickness" id="thickness">
            <option>Select One</option>
            <option>1 3/8</option>
          </select></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><div align="center"><strong>Width (in inches)</strong><br />
                <input id="width" name="width" size="6" />
      &nbsp;&nbsp;&amp;&nbsp;&nbsp;
                <select name="widthincrements" size="1">
                 <option selected="selected" option value="0">0/8</option>
    <option value=".125">1/8</option>
    <option value=".250 ">1/4</option>
    <option value=".375">3/8</option>
    <option value=".500">1/2</option>
    <option value=".625">5/8</option>
    <option value=".750">3/4</option>
    <option value=".875">7/8</option> 
                </select>
    <br>
              </div></td>
              <td><div align="center">x</div></td>
              <td><div align="center"><strong>Height (in inches)</strong><br />
                <input id="height" name="height" size="6" />
      &nbsp;&nbsp;&amp;&nbsp;&nbsp;
                <select size="1" name="heightincrements">
                <option selected="selected" option value="0">0/8</option>
    <option value=".125">1/8</option>
    <option value=".250 ">1/4</option>
    <option value=".375">3/8</option>
    <option value=".500">1/2</option>
    <option value=".625">5/8</option>
    <option value=".750">3/4</option>
    <option value=".875">7/8</option> 
                </select>
    <br>
              </div></td>
            </tr>
          </table></td>
          <td><div align="center"><strong>Quantity (# of Pairs)</strong><br />
                <input ID="quantity" NAME="quantity" SIZE="6">
          </div></td>
        </tr>
        <tr>
          <td valign="top">Add-Ons Per Pair
            <br />
            <br />        <table width="100%" border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td align="center" valign="top"><label>
                  <div align="center"><strong>Priming $50 </strong><br />
                      <select name="priming" id="priming">
                        <option value="0">No Thank you</option>
                        <option option="option" value="50">Add to Order</option>
                      </select>
                      </label>
                    </div></td>
                <td align="center" valign="top"><label>
                    <div align="center"><strong>Faux Tilt Rods $50 </strong><br />
                      <select name="fauxtiltrods" id="fauxtiltrods">
                        <option value="0" selected="selected">No Thank you</option>
                        <option value="50">Add to Order</option>
                      </select>
                      </label>
                    </div></td>
                <td align="center" valign="top"><label>
                    <div align="center"><strong>Copper Caps $70</strong> <br />
                      <select name="coppercaps" id="coppercaps">
                        <option value="0" selected="selected">No Thank you</option>
                        <option value="70">Add to Order</option>
                      </select>
                      </label>
                    </div></td>
                </tr>
              <tr>
                <td align="center" valign="top"><div align="center"><strong>Horns $50</strong> <br />
                  <select name="horns" id="horns">
                    <option value="0" selected="selected">No Thank you</option>
                    <option value="50">Add to Order</option>
                  </select>
                </div></td>
                <td align="center" valign="top"><div align="center"><strong>Arches $150</strong> <br />
                  <select name="arches" id="arches">
                    <option value="0" selected="selected">No Thank you</option>
                    <option value="150">Add to Order</option>
                  </select>
                </div></td>
                <td align="center" valign="top"><div align="center"></div></td>
                </tr>
            </table>
            <br></td>
          <td><div align="center">
      <input ID="calculate" TYPE="button" NAME="Calculate" VALUE="Calculate" onClick="CLcalc();">
      &nbsp;&nbsp;Or&nbsp;&nbsp;
            <input name="Reset" TYPE="reset" ID="reset" value="Reset">
            <br>
            <br>
            <span class="style1">Price per Pair:</span><br />
            $&nbsp;
            <input ID="pairprice" NAME="CostClosedLouverPair" SIZE="8" style="background-color: #ffffff" disabled="true"> 
              <br>
              <br>
              <span class="style1">Total:</span><br />
            $&nbsp;
            <input ID="quantityprice" NAME="CostClosedLouverTotal" SIZE="8" style="background-color: #ffffff" disabled="true">
          </div></td>
        </tr>
      </table>
      <br />
    If you want to change your specificaions, please hit the &quot;Calculate&quot; button again for an accurate calculation.</div>
    <label></label>
    <div align="left"><br />
        <span class="style1">Customer Information</span><br />
      Fields marked with an * are required.<br />
      <br />
      <table width="50%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="center" valign="top"><label>
            <div align="left"><strong>Name</strong><br />
              <input name="Name" type="text" id="Name" value="*" />
              </div>
            </label></td>
          </tr>
        <tr>
          <td align="center" valign="top"> <label>
            <div align="left"><strong>Phone</strong><br />
              <input name="phone" type="text" id="phone" value="*" />
              </div>
            </label></td>
          </tr>
        <tr>
          <td align="center" valign="top"> <label>
              <div align="left"><strong>E-Mail          </strong><br />
                <input name="email" type="text" id="email" value="*" />
                </div>
            </label></td>
          </tr>
        <tr>

  4. #4
    Join Date
    May 2011
    Posts
    7

    code pt 3

    Code:
    <td align="center" valign="top"><div align="left"><strong>Address Line 1</strong><br />        
                <input name="addressline1" type="text" id="addressline1" value="*" />      
            </div></td>
          </tr>
        <tr>
          <td align="center" valign="top"><div align="left"><strong>Address Line 2</strong><br />        
                <input type="text" name="addressline2" id="addressline2" />      
            </div></td>
          </tr>
        <tr>
          <td align="center" valign="top"><div align="left"><strong>City</strong><br />        
                <input name="city" type="text" id="city" value="*" />      
            </div></td>
          </tr>
        <tr>
          <td align="center" valign="top"><div align="left"><strong>State</strong><br />
            <select name="state" size="1">
              <option selected="selected">State</option>
              <option value="">-- UNITED STATES --</option>
              <option value="AL">Alabama</option>
              <option value="AK">Alaska</option>
              <option value="AZ">Arizona</option>
              <option value="AR">Arkansas</option>
              <option value="CA">California</option>
              <option value="CO">Colorado</option>
              <option value="CT">Connecticut</option>
              <option value="DE">Delaware</option>
              <option value="FL">Florida</option>
              <option value="GA">Georgia</option>
              <option value="HI">Hawaii</option>
              <option value="ID">Idaho</option>
              <option value="IL">Illinois</option>
              <option value="IN">Indiana</option>
              <option value="IA">Iowa</option>
              <option value="KS">Kansas</option>
              <option value="KY">Kentucky</option>
              <option value="LA">Louisiana</option>
              <option value="ME">Maine</option>
              <option value="MD">Maryland</option>
              <option value="MA">Massachusetts</option>
              <option value="MI">Michigan</option>
              <option value="MN">Minnesota</option>
              <option value="MS">Mississippi</option>
              <option value="MO">Missouri</option>
              <option value="MT">Montana</option>
              <option value="NE">Nebraska</option>
              <option value="NV">Nevada</option>
              <option value="NH">New Hampshire</option>
              <option value="NJ">New Jersey</option>
              <option value="NM">New Mexico</option>
              <option value="NY">New York</option>
              <option value="NC">North Carolina</option>
              <option value="ND">North Dakota</option>
              <option value="OH">Ohio</option>
              <option value="OK">Oklahoma</option>
              <option value="OR">Oregon</option>
              <option value="PA">Pennsylvania</option>
              <option value="RI">Rhode Island</option>
              <option value="SC">South Carolina</option>
              <option value="SD">South Dakota</option>
              <option value="TN">Tennessee</option>
              <option value="TX">Texas</option>
              <option value="UT">Utah</option>
              <option value="VT">Vermont</option>
              <option value="VA">Virginia</option>
              <option value="WA">Washington</option>
              <option value="WV">West Virginia</option>
              <option value="WI">Wisconsin</option>
              <option value="WY">Wyoming</option>
              <option value="">-- CANADA --</option>
              <option value="AB">Alberta</option>
              <option value="BC">British Columbia</option>
              <option value="MB">Manitoba</option>
              <option value="NB">New Brunswick</option>
              <option value="NF">Newfoundland and Labrador</option>
              <option value="NT">Northwest Territories</option>
              <option value="NS">Nova Scotia</option>
              <option value="NU">Nunavut</option>
              <option value="ON">Ontario</option>
              <option value="PE">Prince Edward Island</option>
              <option value="PQ">Quebec</option>
              <option value="SK">Saskatchewan</option>
              <option value="YT">Yukon Territory</option>
              <option value="">-- AUSTRALIA --</option>
              <option value="AC">Australian Capital Territory</option>
              <option value="NW">New South Wales</option>
              <option value="NO">Northern Territory</option>
              <option value="QL">Queensland</option>
              <option value="SA">South Australia</option>
              <option value="TS">Tasmania</option>
              <option value="VC">Victoria</option>
              <option value="WS">Western Australia</option>
              </select>
            *</div></td>
          </tr>
        <tr>
          <td align="center" valign="top"><div align="left"><strong>Zip Code</strong><br />        
                <input name="zipcode" type="text" id="zipcode" value="*" />      
            </div></td>
          </tr>
      </table>
      <br />
      <br />
      <input type="submit" name="placeorder" id="placeorder" value="Place Order" />
    </div>
    </FORM>
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.14227 seconds
  • Memory Usage 2,910KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates