Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask PHP Expert

<HTML>

<HEAD><TITLE>Order Form</TITLE>

<SCRIPT>

// function to calculate the total cost field function Total()

{ var tot = 0;

tot += (240 * document.order.qty1.value); tot += (270 * document.order.qty2.value); tot += (300 * document.order.qty3.value); tot += (600 * document.order.qty4.value); document.order.totalcost.value  = tot; }

// function to update cost when quantity is changed function UpdateCost(number, unitcost)

{ costname = "cost" + number; qtyname = "qty" + number; var q = document.order[qtyname].value;

document.order[costname].value  = q * unitcost;

Total();

}

// function to copy billing address to shipping address function CopyAddress()

{ if (document.order.same.checked)

{ document.order.shipto.value = document.order.billto.value;

}

}

//global variable for error flag var errfound = false;

//function to validate by length function ValidLength(item, len)

{ return (item.length >= len); }

//function to authorize any email address function Valid Email (item)

{ if (!ValidLength(item, 5)) return false;

if (item.indexOf ('@', 0) == -1)

return false;

return true;

}

function error(elem, text)

{

// abort if we already found an error if (errfound) return; window.alert(text);

elem.select(); elem.focus(); errfound = true;

}

// main validation function function Validate()

{

errfound = false;

if (!ValidLength(document.order.name1.value,6))

error(document.order.name1,"Invalid  Name");

if (!ValidLength(document.order.phone.value,10))

error(document.order.phone,"Invalid  Phone");

if (!ValidLength(document.order.billto.value,30))

error(document.order.billto,"Invalid  Billing Address");

 if (!ValidLength(document.order.shipto.value,30))

error(document.order.shipto,"Invalid  Shipping Address");

if (!ValidEmail(document.order.email.value)) error(document.order.email, "Invalid Email Address");

if (document.order.totalcost.value  == "") error(document.order.qty1, "Please Order at least one item.");

 if (document.order.payby.selectedIndex  != 1)

{

if (!ValidLength(document.order.creditno.value,2))

error(document.order.creditno,"Invalid Credit/Check number");

}

return !errfound; /* true if there are no errors */ }

</SCRIPT> </HEAD>

<BODY>

<H1>Online Cake Order Form</H1>

<FORM NAME="order" onSubmit="return Validate();">

<B>Name:</B>

<INPUT TYPE="text" NAME="name1" SIZE=20>

<B>Phone: </B>

<INPUT TYPE="text" NAME="phone" SIZE=15>

<B>E-mail address:</B>

<INPUT TYPE="text" NAME="email" SIZE=20><BR><BR>

<B>Shipping Address:</B>

<BR>

<TEXTAREA  NAME="shipto"  COLS=40  ROWS=4 onChange="CopyAddress();"> Enter your shipping address here. </TEXTAREA>

<B>Products to Order:</B><BR>

Qty:  <INPUT  TYPE="TEXT"  NAME="qty1"  VALUE="0"  SIZE=4  onChange  = "UpdateCost(1, 240);">

Cost:  <INPUT  TYPE="TEXT"  NAME="cost1"  SIZE=6>  (Rs.240  )  Vanilla  cake

<BR>

Qty:  <INPUT  TYPE="TEXT"  NAME="qty2"  VALUE="0"  SIZE=4  onChange  = "UpdateCost(2, 270);">

Cost: <INPUT TYPE="TEXT" NAME="cost2" SIZE=6> (Rs.270 ) Strawberry cake

<BR>

Qty:  <INPUT  TYPE="TEXT"  NAME="qty3"  VALUE="0"  SIZE=4  onChange  = "UpdateCost(3, 300);">

Cost:  <INPUT  TYPE="TEXT"  NAME="cost3"  SIZE=6>  (Rs.300  )  Black  Forest cake <BR>

Qty:  <INPUT  TYPE="TEXT"  NAME="qty4"  VALUE="0"  SIZE=4  onChange  = "UpdateCost(4, 600);">

Cost: <INPUT TYPE="TEXT" NAME="cost4" SIZE=6> (Rs.600 ) Chocolate cake

<HR>     <B>Total     Cost:</B>     <INPUT     TYPE="TEXT"     NAME="totalcost" SIZE=8><HR> <B>

Method of Payment</B>:

<SELECT NAME="payby"> <OPTION VALUE="check" SELECTED> Check or Money Order

<OPTION VALUE="cash">Cash or Cashier's Check

<OPTION VALUE="credit">Credit Card (specify number)

</SELECT><BR> <B>Credit Card or Check Number:</B>:

<INPUT TYPE="TEXT" NAME="creditno" SIZE="20"><BR>

<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Send Your Order">

<INPUT TYPE="RESET" VALUE="Clear Form">

</FORM>

</BODY>

</HTML>

PHP , Programming

  • Category:- PHP
  • Reference No.:- M9539575

Have any Question?


Related Questions in PHP

Question develop a 5-6 page word document that describes

Question: Develop a 5-6 page Word document that describes the design for a small Web site that meets the following specifications. 1. The Web site includes four or more Web pages designed according to current usability g ...

Final project assignment -requirements specifications -1

FINAL PROJECT ASSIGNMENT - REQUIREMENTS / SPECIFICATIONS - 1. For the final project, you will have to make good use of your CMS using PHP and MySQL for the content delivery. You will have to be able to deliver the conten ...

Question continue to build on the skills of providing web

Question: Continue to build on the skills of providing Web page content and structure with HTML and Web page style and layout using CSS. Demonstrate the skill of creating a dynamic Web page that includes JavaScript clien ...

In php write a simple addtion calculator that reads in two

In PHP write a simple addtion calculator that reads in two values and then add them together and display the output. Be sure to validate both inputs and ensure that it can add 0+0 = Sum: 0. The user should be able to inp ...

Question using the course software and week one template as

Question: Using the course software and Week One Template as a starting point, create a new HTML webpage and include the following: • Write the code to display your name in the largest-size heading element. • Write the m ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As