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

I need help in a website updates, I need help in a Website Updates I do ...

I need help in a Website Updates I do like the make the subsequent changes to my website: 1 Add tag line beneath logo to home page 2 Add about section to right of home page w

I need help to develop a web app, I need help to develop a Web App The j...

I need help to develop a Web App The job will include developing a website and advertising platform Job Description- We're looking for a Web Developer. Your responsibiliti

Need help to revamp an existing website, Website Designing Need help to ...

Website Designing Need help to revamp an existing website Job description: Need to change the look of an existing website so that it can have greater hits Web developme

Need help for a proposal for electronic medical record, Proposal for electr...

Proposal for electronic medical record I'm development an online electronic medical record custody application for a third country as well as need a proposal for funding. I want

I need web scrapers written, I Need web scrapers WRITTEN I have five sit...

I Need web scrapers WRITTEN I have five sites (very simple) whose web scrapers I need written ASAP. I am seeking for someone who can start IMMEDIATELY as well as work on this fo

Need help for psd to responsive html5/css3, PSD to Responsive HTML5 / CSS3 ...

PSD to Responsive HTML5 / CSS3 I want someone who can offer a rapid reversal on this project. We will provide you with the full PSD file we will need you to create a five pag

Need help to develop map-based community website, Develop Map-based communi...

Develop Map-based community website Community website allowing registered users as well as non-registered guests to post their location on a Google map. Visitors can then search

We need help in qr code generator development estimate, QR Code Generator D...

QR Code Generator Development Estimate We would like to demand of you an estimate for merging the following html software attached from our posting and Google Chart API necessar

We need a web developer, We need a web developer We have a very modest t...

We need a web developer We have a very modest three page site on go daddy and just want someone to design it through the go daddy site. We as well would like a logo designed.

Want help in wordpress oauth plugin, Want help WordPress OAuth Plugin We...

Want help WordPress OAuth Plugin We have written a Wordpress oauth plugin that delivers Wordpress authentication via our oauth provider at PlayGrid.com. The present plugin has a

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