Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Pizza Parlor</title>
- <link rel="stylesheet" type="text/css" media="all" href="pizzaParlor.css" />
- <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
- <script type="text/javascript" src="pizzaParlor.js"></script>
- <script>
- //<!--
- var message = "";
- // Here are 2 ways you could setup the javascript to handle this form.
- // Lets setup our order in an Array
- /*
- * index - Description of what it holds.
- * 0 - Size of Pizza
- * 1 - Crust type
- * 2 - Type of pizza
- * 3 - Array of toppings.
- */
- var order = new Array(" "," "," "," ");
- var price = new Array(" "," "," "," ");
- var total = 0;
- var pizza12 = 5.00;
- var pizza16 = 6.00;
- var pizza20 = 7.00;
- var specHawa = 2.00;
- var specVeg = 2.00;
- var specMeat = 3.00;
- var crustHand = 2.00;
- var crustDeep = 3.00;
- //Another way would be to create an order object.
- /* -----------------------------------------------------
- * name: isSpecialty()
- * purpose: Checks Pizza Type.
- * author: Eric Collins
- * date: 03/03/2014
- * parameters: none
- */
- function isSpecialty(){
- if(jquery("input:radio[name=custom]:checked").val() == "Hawaiian"){
- order[3] = false;
- price[3] = "2"
- return true;
- } else if($("input:radio[name=custom]:checked").val() == "Veggie") {
- order[3] = false;
- price[3] = "2"
- return true;
- } else if($("input:radio[name=custom]:checked").val() == "MeatLovers") {
- order[3] = false;
- price[3] = "3"
- return true;
- } else {
- // Is Custom
- order[3] = true;
- price[3] = "3"
- return false;
- } // end if else
- } // end function isBuildYourOwn()
- /* -----------------------------------------------------
- * name: addSize()
- * purpose: Checks Pizza Type.
- * author: Eric Collins
- * date: 03/03/2014
- * parameters: none
- */
- function addSize(){
- if($("input:radio[name=size]:checked").val() == "12"){
- order[0] = "12 inch pie";
- } else if($("input:radio[name=size]:checked").val() == "16"){
- order[0] = "16 inch pie";
- } else if($("input:radio[name=size]:checked").val() == "20"){
- order[0] = "20 inch pie";
- } // end if else
- if($("input:radio[name=size]:checked").val() == "12"){
- price[0] = 5;
- } else if($("input:radio[name=size]:checked").val() == "16"){
- price[0] = 6;
- } else if($("input:radio[name=size]:checked").val() == "20"){
- price[0] = 7;
- } // end if else
- updateDisplay();
- } // end function addSize()
- /* -----------------------------------------------------
- * name: addCrust()
- * purpose: Checks Pizza Type.
- * author: Eric Collins
- * date: 03/03/2014
- * parameters: none
- */
- function addCrust(){
- if($("input:radio[name=crust]:checked").val() == "Hand-Tossed"){
- order[1] = "Hand-Tossed";
- price[1] = "2";
- } else if($("input:radio[name=crust]:checked").val() == "Deep Dish"){
- order[1] = "Deep Dish";
- price[1] = "3";
- } // end if else
- updateDisplay();
- } // end function addCrust()
- /* -----------------------------------------------------
- * name: addType()
- * purpose: Adds Pizza Type: Speciality(Hawaiian, Veggie, Meat Lovers) or Custom.
- * author: Eric Collins
- * date: 03/03/2014
- * parameters: none
- */
- function addType(){
- if($("input:radio[name=custom]:checked").val() == "Hawaiian"){
- // put your code here for disabling the topping check boxes of custom.
- // Maybe call a function which disables those Elements of the form.
- disableTop();
- order[2] = "Hawaiian";
- price[2] = "2"
- } else if($("input:radio[name=custom]:checked").val() == "Veggie"){
- // put your code here for disabling the topping check boxes of custom.
- // Maybe call a function which disables those Elements of the form.
- disableTop();
- order[2] = "Veggie";
- price[2] = "2"
- } else if($("input:radio[name=custom]:checked").val() == "MeatLovers"){
- // put your code here for disabling the topping check boxes of custom.
- // Maybe call a function which disables those Elements of the form.
- disableTop();
- order[2] = "Meat Lovers";
- price[2] = "3"
- } else if($("input:radio[name=custom]:checked").val() == "BuildYourOwn"){
- // put your code here for enable the topping check boxes of custom.
- // Maybe call a function which enables those Elements of the form.
- enableTop();
- order[2] = "Build Your Own";
- price[2] = "2"
- }// end if else
- updateDisplay();
- } // end function addCrust()
- function disableTop(){
- // JavaScript
- document.getElementById('top01').disabled = true;
- document.getElementById('top02').disabled = true;
- document.getElementById('top03').disabled = true;
- //$('#top01').attr("disabled", true);
- //$('#top02').attr("disabled", true);
- //$('#top03').attr("disabled", true);
- // jQuery
- $('#top04').attr("disabled", true);
- $('#top05').attr("disabled", true);
- $('#top06').attr("disabled", true);
- $('#tbltop').addClass('disabled');
- } // end function disableTop()
- function enableTop(){
- $('#top01').attr("disabled", false);
- $('#top02').attr("disabled", false);
- $('#top03').attr("disabled", false);
- $('#top04').attr("disabled", false);
- $('#top05').attr("disabled", false);
- $('#top06').attr("disabled", false);
- $('#tbltop').removeClass('disabled');
- } // end function enableTop()
- /* -----------------------------------------------------
- * name: updateDisplay()
- * purpose: Updates the shopping cart with any changes in order.
- * author: Eric Collins
- * date: 03/03/2014
- * parameters: none
- */
- function updateDisplay(){
- //alert("updateDisplay was called");
- //alert(order[0]);
- $('#messages').text("");
- for(var i = 0; i < order.length; i++){
- $('#messages').append(order[i] + " " + price[i] + "<br />");
- } // end for loop
- subTotal(order);
- } // end function updateDisplay()
- /* -----------------------------------------------------
- * name: subTotal()
- * purpose: Adds together the total for the pizza
- * author: Chris Comstock
- * date: 03/17/2014
- * parameters: none
- */
- function subTotal(order){
- var subTot;
- var subTotVal = order;
- //alert(subTotVal);
- if (subTotVal[0] == "12 inch pie") {
- document.getElementById("subTotal").innerHTML = pizza12;
- if (subTotVal[2] == "Hawaiian") {
- var subTot = pizza12 + specHawa;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- if (subTotVal[2] == "Veggie") {
- var subTot = pizza12 + specVeg;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- if (subTotVal[2] == "Meat Lovers") {
- var subTot = pizza12 + specMeat;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- else if(subTotVal[0] == "16 inch pie")
- document.getElementById("subTotal").innerHTML = pizza16;
- if (subTotVal[2] == "Hawaiian") {
- var subTot = pizza16 + specHawa;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- if (subTotVal[2] == "Veggie") {
- var subTot = pizza16 + specVeg;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- if (subTotVal[2] == "Meat Lovers") {
- var subTot = pizza16 + specMeat;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- else (subTotVal[0] == "20 inch pie")
- document.getElementById("subTotal").innerHTML = pizza20;
- if (subTotVal[2] == "Hawaiian") {
- var subTot = pizza20 + specHawa;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- if (subTotVal[2] == "Veggie") {
- var subTot = pizza20 + specVeg;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- if (subTotVal[2] == "Meat Lovers") {
- var subTot = pizza20 + specMeat;
- subTot = parseFloat(subTot).toFixed(2);
- document.getElementById("subTotal").innerHTML = "$" + subTot;
- }
- } //end if
- }//end totalCost() function
- /* -----------------------------------------------------
- * name: clearDisplay()
- * purpose: Clears the shopping cart display.
- * author: Eric Collins
- * date: 03/03/2014
- * parameters: none
- */
- function clearDisplay(){
- $('#tbltop').removeClass('disabled');
- $('#messages').text("");
- for(var i = 0; i < order.length; i ++){
- order[i] = " ";
- price[i] = " ";
- total = 0;
- } // end for loop
- } // end function clearDisplay()
- /* -----------------------------------------------------
- * name: yumCookies()
- * purpose: Places form data in cookies.
- * author: Eric Collins
- * date: 03/12/2014
- * parameters: none
- */
- function yumCookies(){
- var pizzaSize = order[0];
- var pizzaCrust = order[1];
- var pizzaType = order[2];
- //alert(pizzaSize);
- //alert(pizzaCrust);
- //alert(pizzaType);
- SetCookie("pizSZ", pizzaSize);
- SetCookie("pizzaCRST", pizzaCrust);
- SetCookie("pizzaTyp", pizzaType);
- SetCookie("totalCST", total);
- //temp = GetCookie("pizSZ");
- //alert(GetCookie("pizSZ"));
- //alert(GetCookie("pizzaCRST"));
- //alert(GetCookie("pizzaTyp"));
- //alert(temp);
- } // end function yumCookies()
- //-->
- //-->
- </script>
- </head>
- <body>
- <div id="wrapper" class="wrapper">
- <div id="header" class="header">
- <img src="images/pizzaParlorLogo.png" alt="LogoImage" height="100" width="150" style="float: left;" />
- <h1>Pizza Parlor</h1>
- <span style="text-align: right;">(425) 555-1212</span><br />
- <span style="text-align: right;">555 5th Ave</span><br />
- <span style="text-align: right;">Everett, WA 98203</span>
- </div>
- <!-- horizontal menu -->
- <div id="horizontalMenu" style="text-align: center; font-size: 10px;">
- <a href="#">Home</a>
- <a href="#">Order Now</a>
- <a href="#">Contact Us</a>
- </div>
- <!-- horizontal menu -->
- <br />
- <div id="content" class="main">
- <div id="center" class="yourOrder">
- <h2>Create your Order</h2>
- <hr />
- <form name="shopcart" action="custInfo.html" method="post">
- <span style="color: white;">Select your pizza size:</span>
- <input type="radio" name="size" value="12" class="pieSize" onclick="addSize()" /> 12"
- <input type="radio" name="size" value="16" class="pieSize" onclick="addSize()" /> 16"
- <input type="radio" name="size" value="20" class="pieSize" onclick="addSize()" /> 20"
- <hr />
- <span style="color: white;">Select your crust type:</span>
- <input type="radio" name="crust" value="Hand-Tossed" onclick="addCrust()" /> Hand-tossed
- <input type="radio" name="crust" value="Deep Dish" onclick="addCrust()" /> Deep dish
- <hr />
- <span style="color: white;">Build your own:</span>
- <input type="radio" name="custom" value="BuildYourOwn" onclick="addType()" /> Custom<br />
- <br />
- <table id="tbltop">
- <tbody>
- <tr>
- <td><input type="checkbox" id="top01" name="topping" value="Pineapple"/> Pineapple</td>
- <td><input type="checkbox" id="top02" name="topping" value="Chicken"/> Chicken</td>
- <td><input type="checkbox" id="top03" name="topping" value="Canadian Bacon"/> Canadian Bacon</td>
- </tr>
- <tr>
- <td><input type="checkbox" id="top04" name="topping" value="Sausage"/> Sausage</td>
- <td><input type="checkbox" id="top05" name="topping" value="Pepperoni"/> Pepperoni</td>
- <td><input type="checkbox" id="top06" name="topping" value="Tomatoes"/> Tomatoes</td>
- </tr>
- </tbody>
- </table>
- <br />
- <table>
- <tbody>
- <tr>
- <td colspan="2" style="color: white;">
- Or Select from one of our speciality pizza
- </td>
- <td><input type="radio" name="custom" value="Hawaiian" onclick="addType()" /> Hawaiian</td>
- </tr>
- <tr>
- <td colspan="2"> </td>
- <td><input type="radio" name="custom" value="Veggie" onclick="addType()" /> Veggie</td>
- </tr>
- <tr>
- <td colspan="2"> </td>
- <td><input type="radio" name="custom" value="MeatLovers" onclick="addType()" /> Meat Lovers</td>
- </tr>
- </tbody>
- </table>
- <br /><br />
- <table>
- <tr>
- <td><input type="submit" name="submit" value="submit" onclick="yumCookies()"/></td>
- <td><input type="reset" name="reset" value="reset" onclick="clearDisplay()" /></td>
- </tr>
- </table>
- </form>
- </div>
- <div id="rightSidebar" class="shoppingCart">
- <h2>Shopping Cart</h2>
- <div id="messages"> </div><br/>
- <div id="subTotal"> </div>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement