Advertisement
Guest User

Untitled

a guest
Mar 19th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.03 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.  
  6. <title>Pizza Parlor</title>
  7.  
  8. <link rel="stylesheet" type="text/css" media="all" href="pizzaParlor.css" />
  9.  
  10. <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  11. <script type="text/javascript" src="pizzaParlor.js"></script>
  12. <script>
  13. //<!--
  14.  
  15. var message = "";
  16.  
  17.  
  18. // Here are 2 ways you could setup the javascript to handle this form.
  19. // Lets setup our order in an Array
  20. /*
  21. * index - Description of what it holds.
  22. * 0 - Size of Pizza
  23. * 1 - Crust type
  24. * 2 - Type of pizza
  25. * 3 - Array of toppings.
  26. */
  27. var order = new Array(" "," "," "," ");
  28. var price = new Array(" "," "," "," ");
  29. var total = 0;
  30. var pizza12 = 5.00;
  31. var pizza16 = 6.00;
  32. var pizza20 = 7.00;
  33. var specHawa = 2.00;
  34. var specVeg = 2.00;
  35. var specMeat = 3.00;
  36. var crustHand = 2.00;
  37. var crustDeep = 3.00;
  38.  
  39.  
  40. //Another way would be to create an order object.
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. /* -----------------------------------------------------
  48. * name: isSpecialty()
  49. * purpose: Checks Pizza Type.
  50. * author: Eric Collins
  51. * date: 03/03/2014
  52. * parameters: none
  53. */
  54. function isSpecialty(){
  55. if(jquery("input:radio[name=custom]:checked").val() == "Hawaiian"){
  56. order[3] = false;
  57. price[3] = "2"
  58. return true;
  59. } else if($("input:radio[name=custom]:checked").val() == "Veggie") {
  60. order[3] = false;
  61. price[3] = "2"
  62. return true;
  63. } else if($("input:radio[name=custom]:checked").val() == "MeatLovers") {
  64. order[3] = false;
  65. price[3] = "3"
  66. return true;
  67. } else {
  68. // Is Custom
  69. order[3] = true;
  70. price[3] = "3"
  71. return false;
  72. } // end if else
  73. } // end function isBuildYourOwn()
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. /* -----------------------------------------------------
  86. * name: addSize()
  87. * purpose: Checks Pizza Type.
  88. * author: Eric Collins
  89. * date: 03/03/2014
  90. * parameters: none
  91. */
  92. function addSize(){
  93. if($("input:radio[name=size]:checked").val() == "12"){
  94. order[0] = "12 inch pie";
  95.  
  96. } else if($("input:radio[name=size]:checked").val() == "16"){
  97. order[0] = "16 inch pie";
  98.  
  99. } else if($("input:radio[name=size]:checked").val() == "20"){
  100. order[0] = "20 inch pie";
  101. } // end if else
  102.  
  103. if($("input:radio[name=size]:checked").val() == "12"){
  104. price[0] = 5;
  105. } else if($("input:radio[name=size]:checked").val() == "16"){
  106. price[0] = 6;
  107. } else if($("input:radio[name=size]:checked").val() == "20"){
  108. price[0] = 7;
  109. } // end if else
  110.  
  111. updateDisplay();
  112. } // end function addSize()
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. /* -----------------------------------------------------
  124. * name: addCrust()
  125. * purpose: Checks Pizza Type.
  126. * author: Eric Collins
  127. * date: 03/03/2014
  128. * parameters: none
  129. */
  130. function addCrust(){
  131. if($("input:radio[name=crust]:checked").val() == "Hand-Tossed"){
  132. order[1] = "Hand-Tossed";
  133. price[1] = "2";
  134. } else if($("input:radio[name=crust]:checked").val() == "Deep Dish"){
  135. order[1] = "Deep Dish";
  136. price[1] = "3";
  137. } // end if else
  138.  
  139. updateDisplay();
  140. } // end function addCrust()
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150. /* -----------------------------------------------------
  151. * name: addType()
  152. * purpose: Adds Pizza Type: Speciality(Hawaiian, Veggie, Meat Lovers) or Custom.
  153. * author: Eric Collins
  154. * date: 03/03/2014
  155. * parameters: none
  156. */
  157. function addType(){
  158. if($("input:radio[name=custom]:checked").val() == "Hawaiian"){
  159.  
  160. // put your code here for disabling the topping check boxes of custom.
  161. // Maybe call a function which disables those Elements of the form.
  162. disableTop();
  163. order[2] = "Hawaiian";
  164. price[2] = "2"
  165.  
  166. } else if($("input:radio[name=custom]:checked").val() == "Veggie"){
  167.  
  168. // put your code here for disabling the topping check boxes of custom.
  169. // Maybe call a function which disables those Elements of the form.
  170. disableTop();
  171. order[2] = "Veggie";
  172. price[2] = "2"
  173.  
  174. } else if($("input:radio[name=custom]:checked").val() == "MeatLovers"){
  175.  
  176. // put your code here for disabling the topping check boxes of custom.
  177. // Maybe call a function which disables those Elements of the form.
  178. disableTop();
  179. order[2] = "Meat Lovers";
  180. price[2] = "3"
  181.  
  182. } else if($("input:radio[name=custom]:checked").val() == "BuildYourOwn"){
  183.  
  184. // put your code here for enable the topping check boxes of custom.
  185. // Maybe call a function which enables those Elements of the form.
  186. enableTop();
  187. order[2] = "Build Your Own";
  188. price[2] = "2"
  189.  
  190. }// end if else
  191.  
  192. updateDisplay();
  193. } // end function addCrust()
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203. function disableTop(){
  204. // JavaScript
  205. document.getElementById('top01').disabled = true;
  206. document.getElementById('top02').disabled = true;
  207. document.getElementById('top03').disabled = true;
  208.  
  209. //$('#top01').attr("disabled", true);
  210. //$('#top02').attr("disabled", true);
  211. //$('#top03').attr("disabled", true);
  212.  
  213. // jQuery
  214. $('#top04').attr("disabled", true);
  215. $('#top05').attr("disabled", true);
  216. $('#top06').attr("disabled", true);
  217.  
  218. $('#tbltop').addClass('disabled');
  219. } // end function disableTop()
  220.  
  221. function enableTop(){
  222. $('#top01').attr("disabled", false);
  223. $('#top02').attr("disabled", false);
  224. $('#top03').attr("disabled", false);
  225. $('#top04').attr("disabled", false);
  226. $('#top05').attr("disabled", false);
  227. $('#top06').attr("disabled", false);
  228.  
  229. $('#tbltop').removeClass('disabled');
  230. } // end function enableTop()
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243. /* -----------------------------------------------------
  244. * name: updateDisplay()
  245. * purpose: Updates the shopping cart with any changes in order.
  246. * author: Eric Collins
  247. * date: 03/03/2014
  248. * parameters: none
  249. */
  250. function updateDisplay(){
  251. //alert("updateDisplay was called");
  252. //alert(order[0]);
  253. $('#messages').text("");
  254.  
  255. for(var i = 0; i < order.length; i++){
  256. $('#messages').append(order[i] + " " + price[i] + "<br />");
  257.  
  258. } // end for loop
  259. subTotal(order);
  260. } // end function updateDisplay()
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. /* -----------------------------------------------------
  272. * name: subTotal()
  273. * purpose: Adds together the total for the pizza
  274. * author: Chris Comstock
  275. * date: 03/17/2014
  276. * parameters: none
  277. */
  278.  
  279. function subTotal(order){
  280.  
  281. var subTot;
  282. var subTotVal = order;
  283. //alert(subTotVal);
  284.  
  285. if (subTotVal[0] == "12 inch pie") {
  286. document.getElementById("subTotal").innerHTML = pizza12;
  287.  
  288. if (subTotVal[2] == "Hawaiian") {
  289. var subTot = pizza12 + specHawa;
  290. subTot = parseFloat(subTot).toFixed(2);
  291. document.getElementById("subTotal").innerHTML = "$" + subTot;
  292. }
  293.  
  294. if (subTotVal[2] == "Veggie") {
  295. var subTot = pizza12 + specVeg;
  296. subTot = parseFloat(subTot).toFixed(2);
  297. document.getElementById("subTotal").innerHTML = "$" + subTot;
  298. }
  299.  
  300. if (subTotVal[2] == "Meat Lovers") {
  301. var subTot = pizza12 + specMeat;
  302. subTot = parseFloat(subTot).toFixed(2);
  303. document.getElementById("subTotal").innerHTML = "$" + subTot;
  304. }
  305.  
  306.  
  307. else if(subTotVal[0] == "16 inch pie")
  308. document.getElementById("subTotal").innerHTML = pizza16;
  309.  
  310. if (subTotVal[2] == "Hawaiian") {
  311. var subTot = pizza16 + specHawa;
  312. subTot = parseFloat(subTot).toFixed(2);
  313. document.getElementById("subTotal").innerHTML = "$" + subTot;
  314. }
  315.  
  316. if (subTotVal[2] == "Veggie") {
  317. var subTot = pizza16 + specVeg;
  318. subTot = parseFloat(subTot).toFixed(2);
  319. document.getElementById("subTotal").innerHTML = "$" + subTot;
  320. }
  321.  
  322. if (subTotVal[2] == "Meat Lovers") {
  323. var subTot = pizza16 + specMeat;
  324. subTot = parseFloat(subTot).toFixed(2);
  325. document.getElementById("subTotal").innerHTML = "$" + subTot;
  326. }
  327.  
  328. else (subTotVal[0] == "20 inch pie")
  329. document.getElementById("subTotal").innerHTML = pizza20;
  330.  
  331. if (subTotVal[2] == "Hawaiian") {
  332. var subTot = pizza20 + specHawa;
  333. subTot = parseFloat(subTot).toFixed(2);
  334. document.getElementById("subTotal").innerHTML = "$" + subTot;
  335. }
  336.  
  337. if (subTotVal[2] == "Veggie") {
  338. var subTot = pizza20 + specVeg;
  339. subTot = parseFloat(subTot).toFixed(2);
  340. document.getElementById("subTotal").innerHTML = "$" + subTot;
  341. }
  342.  
  343. if (subTotVal[2] == "Meat Lovers") {
  344. var subTot = pizza20 + specMeat;
  345. subTot = parseFloat(subTot).toFixed(2);
  346. document.getElementById("subTotal").innerHTML = "$" + subTot;
  347. }
  348.  
  349. } //end if
  350.  
  351. }//end totalCost() function
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362. /* -----------------------------------------------------
  363. * name: clearDisplay()
  364. * purpose: Clears the shopping cart display.
  365. * author: Eric Collins
  366. * date: 03/03/2014
  367. * parameters: none
  368. */
  369. function clearDisplay(){
  370. $('#tbltop').removeClass('disabled');
  371. $('#messages').text("");
  372.  
  373. for(var i = 0; i < order.length; i ++){
  374. order[i] = " ";
  375. price[i] = " ";
  376. total = 0;
  377. } // end for loop
  378.  
  379. } // end function clearDisplay()
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394. /* -----------------------------------------------------
  395. * name: yumCookies()
  396. * purpose: Places form data in cookies.
  397. * author: Eric Collins
  398. * date: 03/12/2014
  399. * parameters: none
  400. */
  401. function yumCookies(){
  402. var pizzaSize = order[0];
  403. var pizzaCrust = order[1];
  404. var pizzaType = order[2];
  405.  
  406. //alert(pizzaSize);
  407. //alert(pizzaCrust);
  408. //alert(pizzaType);
  409.  
  410. SetCookie("pizSZ", pizzaSize);
  411. SetCookie("pizzaCRST", pizzaCrust);
  412. SetCookie("pizzaTyp", pizzaType);
  413. SetCookie("totalCST", total);
  414.  
  415. //temp = GetCookie("pizSZ");
  416. //alert(GetCookie("pizSZ"));
  417. //alert(GetCookie("pizzaCRST"));
  418. //alert(GetCookie("pizzaTyp"));
  419.  
  420. //alert(temp);
  421. } // end function yumCookies()
  422. //-->
  423.  
  424. //-->
  425. </script>
  426. </head>
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433. <body>
  434. <div id="wrapper" class="wrapper">
  435. <div id="header" class="header">
  436. <img src="images/pizzaParlorLogo.png" alt="LogoImage" height="100" width="150" style="float: left;" />
  437.  
  438. <h1>Pizza Parlor</h1>
  439.  
  440. <span style="text-align: right;">(425) 555-1212</span><br />
  441. <span style="text-align: right;">555 5th Ave</span><br />
  442. <span style="text-align: right;">Everett, WA 98203</span>
  443. </div>
  444. <!-- horizontal menu -->
  445. <div id="horizontalMenu" style="text-align: center; font-size: 10px;">
  446. <a href="#">Home</a>
  447. <a href="#">Order Now</a>
  448. <a href="#">Contact Us</a>
  449. </div>
  450. <!-- horizontal menu -->
  451. <br />
  452. <div id="content" class="main">
  453. <div id="center" class="yourOrder">
  454.  
  455. <h2>Create your Order</h2>
  456. <hr />
  457. <form name="shopcart" action="custInfo.html" method="post">
  458. <span style="color: white;">Select your pizza size:</span>
  459. <input type="radio" name="size" value="12" class="pieSize" onclick="addSize()" /> 12"
  460. <input type="radio" name="size" value="16" class="pieSize" onclick="addSize()" /> 16"
  461. <input type="radio" name="size" value="20" class="pieSize" onclick="addSize()" /> 20"
  462. <hr />
  463. <span style="color: white;">Select your crust type:</span>
  464. <input type="radio" name="crust" value="Hand-Tossed" onclick="addCrust()" /> Hand-tossed
  465. <input type="radio" name="crust" value="Deep Dish" onclick="addCrust()" /> Deep dish
  466. <hr />
  467. <span style="color: white;">Build your own:</span>
  468. <input type="radio" name="custom" value="BuildYourOwn" onclick="addType()" /> Custom<br />
  469. <br />
  470. <table id="tbltop">
  471. <tbody>
  472. <tr>
  473. <td><input type="checkbox" id="top01" name="topping" value="Pineapple"/> Pineapple</td>
  474. <td><input type="checkbox" id="top02" name="topping" value="Chicken"/> Chicken</td>
  475. <td><input type="checkbox" id="top03" name="topping" value="Canadian Bacon"/> Canadian Bacon</td>
  476. </tr>
  477. <tr>
  478. <td><input type="checkbox" id="top04" name="topping" value="Sausage"/> Sausage</td>
  479. <td><input type="checkbox" id="top05" name="topping" value="Pepperoni"/> Pepperoni</td>
  480. <td><input type="checkbox" id="top06" name="topping" value="Tomatoes"/> Tomatoes</td>
  481. </tr>
  482. </tbody>
  483. </table>
  484. <br />
  485. <table>
  486. <tbody>
  487. <tr>
  488. <td colspan="2" style="color: white;">
  489. Or Select from one of our speciality pizza
  490. </td>
  491. <td><input type="radio" name="custom" value="Hawaiian" onclick="addType()" /> Hawaiian</td>
  492. </tr>
  493. <tr>
  494. <td colspan="2">&nbsp;</td>
  495. <td><input type="radio" name="custom" value="Veggie" onclick="addType()" /> Veggie</td>
  496. </tr>
  497. <tr>
  498. <td colspan="2">&nbsp;</td>
  499. <td><input type="radio" name="custom" value="MeatLovers" onclick="addType()" /> Meat Lovers</td>
  500. </tr>
  501. </tbody>
  502. </table>
  503. <br /><br />
  504. <table>
  505. <tr>
  506. <td><input type="submit" name="submit" value="submit" onclick="yumCookies()"/></td>
  507. <td><input type="reset" name="reset" value="reset" onclick="clearDisplay()" /></td>
  508. </tr>
  509. </table>
  510. </form>
  511. </div>
  512.  
  513. <div id="rightSidebar" class="shoppingCart">
  514. <h2>Shopping Cart</h2>
  515. <div id="messages"> </div><br/>
  516. <div id="subTotal"> </div>
  517. </div>
  518. </div>
  519. </div>
  520. </body>
  521. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement