<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <body bgcolor=""> <script> function confirmit() { var notice = "Your address is: "; var ml = 8.99; var mm = 9.99; var ms = 10.99; var hl = 8.99; var hm = 9.99; var hs = 10.99; var total = 0; var pizza = "pizza"; var mighty = " large mighty "; var sm = " small mighty"; var ct=" cheese tom" ; customerdetails = customername = document.order.custname.value pcode= pcode=document.order.pcode.value customername = document.order.custname.value storecard = document.order.briansretirementfund.value alert("Confirming your order details:" + "\n" + customerdetails + "\n" + pcode ); if (document.order.chkmeatylarge.checked) { total += ml; pizza = pizza + mighty; } if (document.order.chkmeatysmall.checked) { total += ms; total += ml; pizza = pizza + sm; } if (document.order.chkmeatymedium.checked) { total += mm; } if (document.order.cheesetomsmall.checked) { total += hl; "\n" pizza = pizza + ct; } notice = notice + order.address.value + "\n"; notice= notice + order.pcode.value + "\n" ; notice = notice + "Your total cost is: £" + total; notice = notice + pizza; alert(notice); } function checkdetails() { var message=""; if (document.order.pcode.value == "") {message = message + "You must fill in your code \n";} else { // if postcode contains characters do further checks // this is not really the best check that can be done // I am using the principle that a postcode contains 7 or 8 characters var postcodecheck; var pcode; pcode = document.order.pcode.value; postcodecheck = "FALSE"; //assume postcode is incorrect unless it is set to true by either of the if statements if (pcode.length == 7) {postcodecheck = "TRUE";} if (pcode.length == 8) {postcodecheck = "TRUE";} {message = message + "Detail Correct \n";} if (postcodecheck =="FALSE") {message = message + "postcode must be 7 or 8 characters including a space \n";} } if (document.order.emailadd.value == "") {message = message + "You must fill in your email \n";} else //if we establish there are some characters do a further check //this code will check if email has an '@' character in { var email = ""; //variable to hold the contents of the form1.email text box var atpresent = "FALSE"; //variable to hold true or false depending if '@' is present or not var emaillength = 0; //hold the length of the string email var lp; //loop variable email = document.order.emailadd.value; emaillength = email.length; atpresent = "FALSE"; for (lp=0; lp<emaillength; lp++){ if (email.charAt(lp) == '@'){ atpresent ="TRUE";} }//end of for loop if (atpresent == "FALSE") {message = message + "your email address must contain an @ symbol \n";} } if (document.order.address.value == "") {message = message + "You must fill in the first address line \n";} } if (document.order.briansretirementfund.value == "") {message = message + "I need your store card number so I can afford to stop teaching you lot \n";} //given we have data in the credit card field do further checks else{ if (document.order.briansretirementfund.value >= 1000000000 && document.order.briansretirementfund.value <= 9999999999) {} //thats ok do nothing else { //its wrong! message = message + "you must enter a 10 digit number for your store card \n" } alert(message); } </script> <title>Pizza Website</title> </head> <body bgcolor="white"> <center> <IMG SRC="images/logo2.jpg" WIDTH="525" HEIGHT="200" BORDER="0" ALT=""> <br /> <td width="50%"> <center> <h2>Welcome to PizzaDome</h2> If you would like to make an order please enter your Address first </center> <form name="order" enctype="text/plain" action="mailto:falseaddress@tiscali.co.uk"> Name <INPUT TEXT name="custname" size=40> <br> email <INPUT TEXT name="emailadd" size=30> <br> postcode <INPUT TEXT name="pcode" size=8> <br> store card no <INPUT TEXT name="briansretirementfund" size=10> </td> <br> Address <input type="" text="" size="80" name="address" /> <br> <br> <h2>Choose your pizza</h2> <br> <br> <hr /> <br> <br> <br> <h3>Mighty Meaty</h3> <IMG SRC="images/meat feast.jpg" WIDTH="50" HEIGHT="50" BORDER="0" ALT=""> <input type="checkbox" name="chkmeatysmall" />Small £ 8.99 <input type="checkbox" name="chkmeatymedium" />med £ 8.99 <input type="checkbox" name="chkmeatylarge" />large £ 8.99 <hr /> <h3>Cheese and Tomato</h3> <img src="images/logopizza.jpg" width="50" height="50" border="0" alt="" /> <input type="checkbox" name="cheesetomsmall" />Small £ 8.99 <input type="checkbox" name="cheesetommed" />med £ 8.99 <input type="checkbox" name="cheesetomlar" />large £ 8.99 <hr /> <br> <p><input type=button value="confirm choice" onclick="confirmit()"; /> <input type=button value="checkdetails" onclick="checkdetails();" /> <input type=submit name="submit" value="submit order" /></p> </form> </center> </body> </html>