Function to calculate the total cost field function, PHP Web Programming

Assignment Help:

<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>


Related Discussions:- Function to calculate the total cost field function

Select tag and pull down lists, The next type of input is a Pull down List....

The next type of input is a Pull down List. With this kind you ought to use rather than and it also contain a closing tag. This control is used while w

I need help for presentation website in progressive design, Presentation we...

Presentation website in progressive design We want a Presentation website in a progressive design with easy CMS. The website will represent a carpenter as well as contain the fo

Need help in html5 mobile app with php & mysql admin site, HTML5 mobile app...

HTML5 mobile app with php & mysql admin site We would like a HTML5 app which users are capable to record locations and upload photo's, other users can rate it, geolocation, Goog

We devour a magento website that we tried to host, Magento Speed optimizati...

Magento Speed optimization We devour a magento website that we tried to host in hostgator and amazon cloud servers. And it still extremely slow. The hosting company says its poo

Need help in wordpress affiliate tracking, Wordpress Affiliate Tracking- Re...

Wordpress Affiliate Tracking- Recurring I am by means of Pay Pal recurring payments on Wordpress. I am having trouble finding as well as setting up the right Wordpress affiliate

Consulting on html5 mobile framework, Fast consulting on HTML5 mobile frame...

Fast consulting on HTML5 mobile framework based on offered web app. Project Description: I have a web app built with PHP/node/ backbone.js/MySQL/jQuery/kinetic.js/canvas, and

Export a dreamweaver document as xml file, Step 1: Select File -> Open, ...

Step 1: Select File -> Open, Step 2: Choose the document which uses a template (and has editable regions)  Step 3: Click Open Step 4: Select File -> Export -> Exp

Create a website for used book buy and sale, In this part of the assignment...

In this part of the assignment, you continue to develop your website for used book buy and sale. You need to develop the following 3 additional web pages each with associate PHP co

Insert images in site, You will study two ways to add images in Dreamweaver...

You will study two ways to add images in Dreamweaver by using Dreamweaver's main menu and by using the Objects panel. 1. Click anywhere within the logo layout cell (the topmost

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd