Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Formulas not accurate?

    Hello,
    First off, I wanted to say thank you to those who have helped me so far. It is amazing being new and struggling with a script and then having one of you turn around and find the problem in a few minutes. This forum is a great learning tool for me.
    Well, now I am having trouble with my formulas for my salmon calculator. When I select seafoodgrill from the pull down menu and then enter 10.99 per lb, 85 % yield, and 25.50 price I get a 23% food cost. That is not correct. The correct answer should be around 24.6%. How have I set up the formula wrong. Any help on this would be appreciated.

    Eric


    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <title>FISH CALCULATOR</title>
    <script language="javascript">

    function reset(){
    var frm=document.calc;
    frm.val1.value="";
    frm.val2.value="";
    frm.val3.value="";
    frm.answer.value="";
    }


    function initialise(){
    }

    function cost(){
    var frm=document.calc;
    var x =parseInt(frm.val1.value)||0;
    var y =parseInt(frm.val2.value)||0;
    var z =parseInt(frm.val3.value)||0;
    if (frm.concept.value=='newportbay')
    frm.answer.value=(((x/3.200)*(100/y)+1.894)/z)*100
    if (frm.concept.value=='stanfords')
    frm.answer.value=(((x/2.462)*(100/y)+2.059)/z)*100
    if (frm.concept.value=='chophouse')
    frm.answer.value=(((x/2.462)*(100/y)+1.593)/z)*100
    if (frm.concept.value=='citygrill')
    frm.answer.value=(((x/2.462)*(100/y)+2.140)/z)*100
    if (frm.concept.value=='manzana')
    frm.answer.value=(((x/2.462)*(100/y)+1.380)/z)*100
    if (frm.concept.value=='henrys')
    frm.answer.value=(((x/2.462)*(100/y)+1.530)/z)*100
    if (frm.concept.value=='seafoodgrill')
    frm.answer.value=((((x/2.462)*(100/y))+1.030)/z)*100
    }

    </script>

    </head>
    <body style="text-align: center; background-image: url(bgfish3gif_100.gif);">
    <span style="font-family: Tahoma"><span style="font-family: Baskerville Old Face"><strong>
    <span style="font-size: 36pt; text-decoration: underline">FISH CALCULATOR</span></strong><br />
    <br />
    <br />
    <strong>
    KING SALMON PLATE COST CALCULATOR</strong></span><br />
    </span>
    <br />
    <form name="calc" >
    <table border="2">
    <tr>
    <td align="center" style="width: 100px; height: 30px;" valign="middle">
    Select<br />
    <select name="concept" size=1>
    <option selected value="">CONCEPT
    <option value="newportbay">newportbay
    <option value="stanfords">stanfords
    <option value="chophouse">chophouse
    <option value="citygrill">citygrill
    <option value="manzana">manzana
    <option value="henrys">henrys
    <option value="seafoodgrill">seafoodgrill
    </select>
    </td>
    <td align="center" style="width: 100px; height: 30px;" valign="middle">
    Per LB Price<br />
    <input type="text" name="val1" size=10 id="Text1">
    </td>
    <td align="center" style="width: 100px; height: 30px;" valign="middle">
    Yield<br />
    <input type="text" name="val2" size=10 id="Text2">
    </td>
    <td align="center" style="width: 100px; height: 30px;" valign="middle">
    Menu Price<br />
    <input type="text" name="val3" size=10 id="Text3">
    </td>
    <td align="center" style="width: 100px; height: 30px" valign="middle">
    =
    Plate Cost<br />
    <input type="text" name="answer" size=10 id="Text4" contenteditable="false">
    </td>
    </tr>
    </table>

    <br />
    <input type="button" value="cost" size=10 onclick="cost()">
    <input type="reset" value="reset" size=10 onclick="reset()">
    <br />
    <br />
    </form>
    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,536
    Thanks
    3
    Thanked 513 Times in 500 Posts
    Code:
    function cost(){
    var frm=document.calc;
    var x =parseFloat(frm.val1.value)||0;// Note parseFloat
    var y =parseFloat(frm.val2.value)||0;
    var z =parseFloat(frm.val3.value)||0;
    if (frm.concept.value=='newportbay')
    frm.answer.value=(((x/3.200)*(100/y)+1.894)/z)*100
    if (frm.concept.value=='stanfords')
    frm.answer.value=(((x/2.462)*(100/y)+2.059)/z)*100
    if (frm.concept.value=='chophouse')
    frm.answer.value=(((x/2.462)*(100/y)+1.593)/z)*100
    if (frm.concept.value=='citygrill')
    frm.answer.value=(((x/2.462)*(100/y)+2.140)/z)*100
    if (frm.concept.value=='manzana')
    frm.answer.value=(((x/2.462)*(100/y)+1.380)/z)*100
    if (frm.concept.value=='henrys')
    frm.answer.value=(((x/2.462)*(100/y)+1.530)/z)*100
    if (frm.concept.value=='seafoodgrill')
    frm.answer.value=((((x/2.462)*(100/y))+1.030)/z)*100
    }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,536
    Thanks
    3
    Thanked 513 Times in 500 Posts
    better
    Code:
    function cost(){
    var frm=document.calc;
    var x =parseFloat(frm.val1.value)||0;
    var y =parseFloat(frm.val2.value)||0;
    var z =parseFloat(frm.val3.value)||0;
    var answ=0;
    if (frm.concept.value=='newportbay')
    answ=(((x/3.200)*(100/y)+1.894)/z)*100;
    if (frm.concept.value=='stanfords')
    answ=(((x/2.462)*(100/y)+2.059)/z)*100;
    if (frm.concept.value=='chophouse')
    answ=(((x/2.462)*(100/y)+1.593)/z)*100;
    if (frm.concept.value=='citygrill')
    answ=(((x/2.462)*(100/y)+2.140)/z)*100;
    if (frm.concept.value=='manzana')
    answ=(((x/2.462)*(100/y)+1.380)/z)*100;
    if (frm.concept.value=='henrys')
    answ=(((x/2.462)*(100/y)+1.530)/z)*100;
    if (frm.concept.value=='seafoodgrill')
    answ=((((x/2.462)*(100/y))+1.030)/z)*100;
    frm.answer.value=answ.toFixed(2);
    
    }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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