Docsity

Creating an Online Pizza Order Form using HTML and JavaScript, Slides of Javascript programming

Partial preview of the text

Download Creating an Online Pizza Order Form using HTML and JavaScript and more Slides Javascript programming in PDF only on Docsity!

Forms and JavaScript

Introduction

  • We want to write an html page for a Pizza shop for getting order from customers online.

Introduction

  • We want to write an html page for a Pizza shop for getting order from customers online.
  • So we need to use HTML form to get the data from our customers.
  • We need to get the following information from them:
    • Name
    • Phone No.
    • Pizza Style
    • Pizza Size
    • Toppings (up to four toppings)

Introduction

  • We want to write an html page for a Pizza shop for getting order from customers online.
  • So we need to use HTML form to get the data from our customers.
  • We need to get the following information from them:
    • Name
    • Phone No.
    • Pizza Style
    • Pizza Size
    • Toppings (up to four toppings)
  • Then we need to output a confirmation page with provided data after the customer clicks the order button using JavaScript (You don’t need to worry about JavaScript implementation.)
  • Lets see the finished work together.

Step 2

  1. Make the slice.jpg image the background of your page by adding BACKGROUND attribute to the BODY element.
  2. Add the line “CS105 Pizzeria” as a H1 header center aligned.
  3. Save the file and see the result with a web browser.

Step 3

  • Specify an area for having Form elements within using

tag. Name the FORM as “order” (Make sure

you are calling it exactly “order” ).

  • Define a table within the Form element ().
  • Define a row within the table ().
  • Define two data cells within the row ().
  • Define two Text Fields one inside each data cell.
  • Name the first text field exactly as “name”.
  • Name the second text field exactly as “tel”.
  • Save and see the result.

Step 5

  • Add the Event Handler attribute to each of the two menus which correspond to any change to the selection of the menus (ONCHANGE).
  • Use predefined JavaScript function alert(message) as the actions corresponding to these event handlers.
  • The alert message for size menu should be “You have changed the size of your pizza!”
  • The alert message for style menu should be “You have changed the style of your pizza!”
  • See the Result using a browser.

Step 6

  • Add another row and a data cell within to your table.
  • Add four checkboxes inside the data cell one for each toppings.
  • Here are the NAME and VALUE of each checkbox (NAME and VALUE attributes): NAME VALUE t1 Pepperoni t2 Black Olives t3 Meat ball t4 Sausage

Step 8

  • Add an Event Handler attribute to order button which corresponds to click event (ONCLICK attribute).
  • The action of this event handler (the value of this attribute) should be a call to the JavaScript function orderPizza() defined at the top of the file with no parameter.
  • Save the file and see the result. We are done!