Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Javascript (https://www.askmehelpdesk.com/forumdisplay.php?f=452)
-   -   Try to make a make a simple Menu (https://www.askmehelpdesk.com/showthread.php?t=324822)

  • Mar 4, 2009, 07:54 AM
    Mitchman
    Try to make a make a simple Menu
    I am trying to make a simples meun but I don't know how it get it to add up the taxes.
    What I need it to do is when the user press the total up order button the appropriate subtotals, taxes and final total will be calculated and displayed.


    This is what I came up with so far. I hope someone can help me.


    <HTML>
    <HEAD>
    <TITLE>Take Out Menu Assignment</TITLE>

    <script type="text/javascript">


    // Start Total Up Order

    function FtoC(FTemp)
    { document.form1.hb.value = (FTemp) * 2.99;
    }

    function CtoF(CTemp)
    { document.form1.total.value = (CTemp * FTemp) * 2.99;
    }

    function AtoB(ETemp)
    { document.form1.cb.value = (ETemp) * 3.99;
    }

    function CtoD(DTemp)
    { document.form1.cbtotal.value = (DTemp * ETemp) * 3.99;
    }


    function EtoF(FTemp)
    { document.form1.chb.value = (FTemp) * 4.99;
    }

    function GtoH(GTemp)
    { document.form1.chbtotal.value = (GTemp * FTemp) * 4.99;
    }


    function ItoJ(HTemp)
    { document.form1.ff.value = (HTemp) * 2.99;
    }

    function LtoK(ITemp)
    { document.form1.fftotal.value = (ITemp * HTemp) * 2.99;
    }

    function MtoN(JTemp)
    { document.form1.gravy.value = (JTemp) * 0.50;
    }

    function OtoP(KTemp)
    { document.form1.gtotal.value = (KTemp * JTemp) * 0.50;
    }


    function QtoR(LTemp)
    {document.form1.chilli.value = (LTemp) * 1.99;
    }

    function StoT(MTemp)
    { document.form1.ctotal.value = (MTemp * LTemp) * 1.99;
    }


    function adder(){
    var x=document.getElementById("tb1").value
    var y=document.getElementById("tb2").value
    var z=document.getElementById("tb4").value
    var r=document.getElementById("tb5").value
    var q=document.getElementById("tb6").value
    var m=document.getElementById("tb7").value
    var b=document.getElementById("tb3").value
    var f=document.getElementById("tb8").value
    var g=document.getElementById("tb9").value
    var h=document.getElementById("tb10").value
    document.getElementById("tb3").value=parseFloat(x) +parseFloat(y)+parseFloat(z)+parseFloat(r)+parseFl oat(q)+parseFloat(m)

    document.getElementById("tb8").value=parseFloat(b) +parseFloat(f)
    document.getElementById("tb9").value=parseFloat(b) +parseFloat(g)
    document.getElementById("tb10").value=parseFloat(b )+parseFloat(f)+parseFloat(g)

    }


    // End Total Up Order

    </script>

    </HEAD>

    <BODY>

    <form name="form1">

    <table width="90%" >
    <tr>
    <td>
    <table>
    <th>item</th><th>price</th><th>quantity</th><th>sub-total</th>
    <tr align="center">
    <td align="left">Hamberger</td>

    <td><input type="text" value="$2.99" size="6" ></td>

    <td><input type = "text" name="total" value="0" size="3" onChange="FtoC(this.value)"></td>

    <td><input type="text" name="hb" value="0.00" id="tb1" size="6" onChange="CtoF(this.value)"></td>

    </tr>
    <tr align="center">
    <td align="left">Cheeseburger</td>

    <td><input type="text" value="$3.99" size="6" ></td>

    <td><input type = "text" name="cbtotal" value="0" size="3" onChange="AtoB(this.value)"></td>

    <td><input type="text" name="cb" value="0.00" id="tb2" size="6" onChange="CtoD(this.value)"></td>

    </tr>
    <tr align="center">
    <td align="left">Chicken Burger</td>

    <td><input type="text" value="$4.99" size="6" ></td>

    <td><input type = "text" name="chbtotal" value="0" size="3" onChange="EtoF(this.value)"></td>

    <td><input type="text" name="chb" value="0.00" id="tb4" size="6" onChange="GtoH(this.value)"></td>


    </tr>
    </table>
    </td>
    <td align="right">
    <table>
    <th>item</th><th>price</th><th>quantity</th><th>sub-total</th>
    <tr align="center">
    <td align="left">French Fries</td>

    <td><input type="text" value="$2.99" size="6" ></td>

    <td><input type = "text" name="fftotal" value="0" size="3" onChange="ItoJ(this.value)"></td>

    <td><input type="text" name="ff" value="0.00" id="tb5" size="6" onChange="LtoK(this.value)"></td>

    </tr>
    <tr align="center">
    <td align="left"><input type="checkbox"> gravy</td>

    <td><input type="text" value="$0.50" size="6" ></td>

    <td><input type = "text" name="gtotal" value="0" size="3" onChange="MtoN(this.value)"></td>

    <td><input type="text" name="gravy" value="0.00" id="tb6" size="6" onChange="OtoP(this.value)"></td>
    </tr>
    <tr align="center">
    <td align="left"><input type="checkbox"> chili</td>

    <td><input type="text" value="$1.99" size="6" ></td>

    <td><input type = "text" name="ctotal" value="0" size="3" onChange="QtoR(this.value)"></td>

    <td><input type="text" name="chilli" id="tb7" value="0.00" size="6" onChange="StoT(this.value)"></td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <table align="center">
    <tr>
    <td >subtotal</td>
    <td><input type="text" id="tb3" size="6"></td>
    </tr>
    <tr>
    <td >pst</td>
    <td><input type="text" value="5.00" id="tb8" size="6"></td>
    </tr>
    <td >gst</td>
    <td><input type="text" value="6.00" id="tb9" size="6"></td>
    </tr>
    <td >total</td>
    <td><input type="text" value="0.00" name="" id=" id=" size=" size="></td>
    </tr>
    <tr>
    <td colspan="></td>
    </tr>
    <tr>
    <td colspan=">
    <input type="button">
    <input type="total up order" value="st" id="adder()">
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>


    </form>

    </BODY>
    </HTML>

  • All times are GMT -7. The time now is 03:10 AM.