HOME  |    TRAINING  |   FREE TUTORIALS   |   JOBS
Find out more about our new RSS feed.
FREE Tutorial
PROFESSIONAL JAVASCRIPT PART 5 - CHECK 'EM OUT - THE ONLINE ORDERING SYSTEM

CATEGORY
SEARCH OUR OTHER TUTORIALS

DESCRIPTION

The online ordering system's information gathering takes place over three pages with a fourth page at the end displaying a final summary of the order which the user can accept or go back and alter if they are not happy. At some point in the checkout process, prior to any credit card details being transmitted to the server, we would normally switch to a secure connection using Secure Sockets Layer (SSL) which encrypts all data before it's sent to the web server.
Click here to be kept informed of our new Tutorials.


This free tutorial is a sample from the book Professional JavaScript.


The first of the four screens splits the main frame into two more frames

  • The top frame contains the 'welcome to the online ordering system' blurb and buttons to go to the next screen.
  • The bottom frame contains our shopping basket and serves the dual purpose of confirming what the user is about to buy and giving them an opportunity to change their mind about the quantities.

First we need to create the frameset page and save it as checkout_frame.htm

<HTML>
<FRAMESET FRAMEBORDER=0 BORDER=0 ROWS="140,*">
<FRAME SCROLLING="NO" SRC="checkout.asp" FRAMEBORDER="NO" 
    NAME="fraCheckoutTop" NORESIZE>
<FRAME SCROLLING="AUTO" SRC="checkoutbasket.asp" FRAMEBORDER="NO" 
    NAME="fraCheckoutBottom" NORESIZE>
</FRAMESET>
</HTML>

Now lets create Checkout.asp, which is displayed in the top part of the frameset. For the cmdNext button a function has been created for the onClick event. Here we check that there is still something left in the basket to buy (after user changes to the basket's contents) using the shopping basket in the lower frame. If there is still something in the basket then we continue to the next page.

The cmdBrowse button gives the shopper another opportunity to shop themselves penniless by going back to the category list page. The JavaScript has been included in the event definition itself as it's just one line so there's little point creating a separate function.

<!--#include file="ServerSideGlobalDef.inc"-->
<HTML>
<HEAD>
<SCRIPT language='javascript'>
function cmdNext_onClick()
{
// if as a result of changes to the basket it's empty, inform user
if (parent.parent.getCookie("Basket") == "")
{
  alert("Your basket is empty - click Continue Shopping to fill it _
     up with our excellent bargains");
}
else
{
  // go to page 2 of checkout process
  this.parent.location.href="personaldetails.asp";
}
return true;
}
</SCRIPT>
</HEAD>

<BODY>
<CENTER>
<FONT FACE="Comic Sans MS" SIZE="3" color="Navy">
Welcome to our secure online ordering system. 
Your current basket contents are listed below. 
<FORM>
Once you're happy with its contents click 
<INPUT NAME="cmdNext" TYPE="button" VALUE="Next" ALIGN=top 
    onClick="cmdNext_onClick()">
to continue <BR>
or click 
<INPUT NAME="cmdBrowse" TYPE="button" VALUE="Continue Shopping" 
    ALIGN=top onClick="parent.location.href='home.asp'"> 
to return to the main screen.
</FORM> 
</FONT>
</CENTER>
</BODY>
</HTML>

Save the page as Checkout.asp

The final page in the checkout frameset is the shopping basket. It's very similar to the main shopping basket and uses the same code by incorporating the Basket.inc file, which does most of the work of displaying the basket. bReadOnly has been set to false so that the user can update the contents of the basket.

<!--#include file="ServerSideGlobalDef.inc"-->
<%
bReadOnly = false;
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="UpdateQty.asp" NAME="frmItems" 
onSubmit="return checkQtys(this)">
<!--#include file="basket.inc"-->

</FORM>
</BODY>
</HTML>

Save the page as CheckoutBasket.asp

Obtaining the User's Details

The next two pages obtain the necessary information about the customer to process their order.

The first page obtains information regarding name and delivery address. We also obtain their e-mail address as we use that later to send them conformation of their order.

Continued...


NEXT PAGE



5 RELATED COURSES AVAILABLE
JAVASCRIPT PROGRAMMING
This training course aims to teach the reader the fundamentals of JavaScript. This course covers topics such as -....
HTML 4.0 INTRODUCTION
To create, format and publish a small website using HTML 4.0. You will learn to create web pages incorporating fo....
INTRODUCTION TO JAVA PROGRAMMING
The aims of this Java training courses is to understand the role that Java plays on the Internet; describe the be....
MICROSOFT VISUAL BASIC V6 INTRODUCTION
To go from the fundamentals of Visual Basic programming to the threshold of Advanced level. Gaining in depth prog....
MICROSOFT VISUAL BASIC 5.0 CLIENT SERVER DEVELOPMENT
This course teaches the skills required to develop client server applications using MS Visual Basic 5.0 Enterpris....
 
0 RELATED JOBS AVAILABLE
CONTACT US
Thursday 28th August 2008  © COPYRIGHT 2008 - VISUALSOFT