Web Analytics Made Easy -
StatCounter paying for persific java claculator/form - CodingForum

Announcement

Collapse
No announcement yet.

paying for persific java claculator/form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • paying for persific java claculator/form

    i a newbi to java but i need a calculator for a website that i am making (for my self this is not an assignment by an employer or anything like that)...please read the offer at the bottom.


    the calculator/form needs to have 5 fields were the viewer can input numbers between 0 and 10,000. each field has to have a title above it (put the title for each one as TITLE so i can easily change it)...and then another field were the following calculation is calculated when a button of some sort at the bottom of the page saying "calculate" is pressed, here is the calculation:

    =sum((((0.79*{form1})+((0.53*{form2})*{form3}))*{form4})*{form5})/10)

    if it isn't against the rules in this forum, i would like to offer $5 to some one who can do this for me to be paid by paypal upon acceptation by myself (i only need one...but i may need a similar calculator in the future)

    if it is against the rules then can a mod change the title and can some one offer me advise were to start?

  • #2
    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

    Try this:-

    Code:
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    
    TITLE 1 <input type = "text" name= "t1" id = "t1" size = "5"><br>
    TITLE 2 <input type = "text" name= "t2" id = "t2" size = "5"><br>
    TITLE 3 <input type = "text" name= "t3" id = "t3" size = "5"><br>
    TITLE 4 <input type = "text" name= "t4" id = "t4" size = "5"><br>
    TITLE 5 <input type = "text" name= "t5" id = "t5" size = "5"><br>
    <input type = "button" value = "Calculate Result" onclick = "calc()"><br><br>
    RESULT<input type= "text" name = "result" id = "result">
    
    <script type = "text/javascript">
    
    function calc() {
    var valid = true;
    var sum = 0;
    var values = new Array();
    for (var i = 1; i<=5; i++) {
    values[i] = parseInt(document.getElementById("t"+i).value);
    if (isNaN(values[i]) || values[i] < 0 || values [i] > 10000) {
    valid = false;
    } 
    }
    if (!valid) {
    alert ("You must enter only numbers from 0 - 10000 in all five boxes")
    return false;
    }
    values[1] = values[1] * 0.79;
    values[2] = values[2] * 0.53;
    sum = (values[1] + values[2]) * values[3];
    sum = sum * values[4] * values[5];
    sum = (sum/10).toFixed(2);  // sum to 2 decimal places
    document.getElementById("result").value = sum;
    }
    
    </script>
    
    
    </BODY>
    </HTML>
    I hqave assumed that the input values are integers (whole numbers). If not, alter
    values[i] = parseInt(document.getElementById("t"+i).value);
    to
    values[i] = parseFloat(document.getElementById("t"+i).value);



    Suggest you pay the $5 to a charity of your choice.


    He thought he saw a Kangaroo
    That worked a coffee-mill:
    He looked again, and found it was
    A Vegetable-Pill.
    "Were I to swallow this," he said,
    "I should be very ill!"
    - Lewis Carroll
    Last edited by Philip M; Apr 7, 2009, 11:34 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

    Comment


    • #3
      it will go to cancer research thanks so much...had to edit a bit of the maths but that was my fault because i didn't explain it very well...thanks again.

      hank you for your donation
      Your contribution will make a real difference to our important work.

      Your Credit Card donation has been processed successfully and you should shortly receive an email from us confirming this transaction.

      If you have any queries about, or difficulties with the online processing of your transaction, please contact our Supporter Services team.

      Telephonedel)

      Email: [email protected]
      Transaction information
      Reference Number: (del)
      Transaction Amount: £5.00
      Last edited by no1bittyboy; Apr 7, 2009, 12:45 PM. Reason: proveing it

      Comment


      • #4
        Good man!

        All the code given in this post has been tested and is intended to address the question asked.
        Unless stated otherwise it is not just a demonstration.

        Comment

        Working...
        X