Results 1 to 2 of 2
  1. #1
    i-did-this is offline Member
    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Default Help with Rounding Up - First Post

    Hi – Everyone

    My first post and a call for help...

    I have the following script that takes two numbers from a simple form, performs multiplication and outputs the result back to the form via the variable ‘price’
    I wish to format the output so that the output is rounded up to the next whole number. E.G. 23.123 = 24

    Can anyone help with the required modification to my script?

    ----------------------------------
    <script type="text/javascript" language="Javascript">

    var v1 = 0;
    var v2 = 0;
    var price = 0;

    function calculate () {
    // The Calculation: change operator in this equation to change the calculation
    price = v1 * v2 * .0005;

    var elem;
    elem = document.getElementById("v1");
    elem.value = v1;
    elem = document.getElementById("v2");
    elem.value = v2;

    elem = document.getElementById("price");
    elem.value = price;
    }

    function setValue(elem) {
    var val = 0.0;
    if (elem.value != "") {
    val = parseFloat(elem.value);
    }
    else {
    val = 0.0;
    }
    switch (elem.id) {
    case "v1": v1 = val; break;
    case "v2": v2 = val; break;
    }
    calculate();
    }
    </script>

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Help with Rounding Up - First Post

    Javascript != Java.
    You need to find a Javascript forum.

    I'm closing this thread.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Rounding?!! Need help!
    By aejames23 in forum New To Java
    Replies: 2
    Last Post: 11-04-2012, 01:10 AM
  2. I need help rounding
    By MrPosotive in forum New To Java
    Replies: 2
    Last Post: 09-27-2012, 04:59 PM
  3. Rounding
    By Moncleared in forum New To Java
    Replies: 2
    Last Post: 11-17-2009, 08:16 AM
  4. Replies: 3
    Last Post: 05-04-2009, 03:15 AM

Posting Permissions

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