Docstoc
EXCLUSIVE OFFER FOR DOCSTOC USERS
Try the all-new QuickBooks Online for FREE.  No credit card required.

E-Commerece

Document Sample
E-Commerece Powered By Docstoc
					                             String Object
<HTML>
<HEAD>
<TITLE>Using the String object</TITLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
//-->
</SCRIPT></HEAD>
<BODY>
<H1>Using the String object </H1>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
str=new String("This is a test of javascript string methods");
myArray=new Array(10);
myArray=str.split(' ');
document.write("str.charAt(3) :" +str.charAt(3) +"<P>");
document.write("str.substring(20,25):"+str.substring(20,25)+"<P>");
document.write("str.toLowerCase() :"+str.toLowerCase()+"<P>");
document.write("str.toUpperCase() :"+str.toUpperCase()+"<P>");
document.write("str.Split(' ') myArray[0] :"+myArray[0]+"<P>");
document.write("str.Split(' ') myArray[1]:"+myArray[1]+"<P>");
//-->
</SCRIPT>
</BODY>
</HTML>

                                                                      1
2
             Write the current date
<HTML>
<HEAD>
<TITLE>Writing the Current Date and Time</TITLE>
</HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
document.write(“Welcome! you are visiting my web site on " + Date())
//-->
</SCRIPT>

</BODY>
</HTML>




                                                                       3
4
<HTML>
<HEAD>
<TITLE>Example - Current Date and Time</TITLE>
</HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
// Store the date in a variable
d = new Date()
dateText = ""

// Get the current day and convert it to the name of the day
dayValue = d.getDay()
if (dayValue == 0)
    dateText += "Sunday"
else if (dayValue == 1)
    dateText += "Monday"
else if (dayValue == 2)
    dateText += "Tuesday"
else if (dayValue == 3)
    dateText += "Wednesday"
else if (dayValue == 4)
    dateText += "Thursday"
else if (dayValue == 5)
    dateText += "Friday"
else if (dayValue == 6)
    dateText += "Saturday"
                                                               5
// Get the current month and convert it to the name of the month
monthValue = d.getMonth()
dateText += " "
if (monthValue == 0)
    dateText += "January"
if (monthValue == 1)
    dateText += "February"
if (monthValue == 2)
    dateText += "March"
if (monthValue == 3)
    dateText += "April"
if (monthValue == 4)
    dateText += "May"
if (monthValue == 5)
    dateText += "June"
if (monthValue == 6)
    dateText += "July"
if (monthValue == 7)
    dateText += "August"
if (monthValue == 8)
    dateText += "September"
if (monthValue == 9)
    dateText += "October"
if (monthValue == 10)
    dateText += "November"
if (monthValue == 11)
    dateText += "December"

                                                                   6
// Get the current year; if it's before 2000, add 1900
if (d.getYear() < 2000)
    dateText += " " + d.getDate() + ", " + (1900 + d.getYear())
else
    dateText += " " + d.getDate() + ", " + (d.getYear())

// Get the current minutes
minuteValue = d.getMinutes()
if (minuteValue < 10)
    minuteValue = "0" + minuteValue

// Get the current hours
hourValue = d.getHours()

// Customize the greeting based on the current hours
if (hourValue < 12)
    {
    greeting = "Good morning!"
    timeText = " at " + hourValue + ":" + minuteValue + " AM"
    }
else if (hourValue == 12)
    {
    greeting = "Good afternoon!"
    timeText = " at " + hourValue + ":" + minuteValue + " PM"
    }
                                                                  7
else if (hourValue < 17)
   {
   greeting = "Good afternoon!"
   timeText = " at " + (hourValue-12) + ":" + minuteValue + "
    PM"
   }
else
   {
   greeting = "Good evening!"
   timeText = " at " + (hourValue-12) + ":" + minuteValue + "
    PM"
   }
// Write the greeting, the date, and the time to the page
document.write(greeting + " It's " + dateText + timeText)
//-->
</SCRIPT>

</BODY>
</HTML>

                                                                8
9
<HTML>
<HEAD>
</HEAD>
<script language="JavaScript">
<!--
function onwindowload()
{
   window.regForm.userlogin.focus();
}


function checkValues()
{

   var   Userlogin=document.regForm.userlogin.value;
   var   UserPassword=document.regForm.userPassword.value;
   var   conPassword=document.regForm.conPassword.value;
   var   userAddress=document.regForm.userAdd.value;
   var   name=document.regForm.Name.value;
   var   maxLength = 15;
   var   minLength = 3;


                                                             10
if(Userlogin.length == 0|| userAddress.length==0||name.length==0)
     {
             alert("Please fill in all values");
             return false;
     }
     if(Userlogin.length < minLength || Userlogin.length > maxLength )
     {
             alert("Login Name is limited to " + minLength + " - " + maxLength + " characters");
             return false;
     }
     if(UserPassword.length < minLength || UserPassword.length > maxLength)
     {
             alert("Password is limited to " + minLength + " - " + maxLength + " characters");
             return false;
     }
     else
     {
             for(i=0;i<Userlogin.length;i++)
             {
                         if(Userlogin.charAt(i) == "," || Userlogin.charAt(i) == ";")
                         {
                                        alert("invalid login name");
                                        return false;
                         }
             }
     }



                                                                                                   11
if(UserPassword!=conPassword)
     {
             alert("Passwords do not match");
             return false;
     }
     return true;
     }
//-->
</script>
<BODY onload="onwindowload()">
<font size="3" face="Arial" color=red><strong></font>
<H3>To Register Please Enter The Following Information:</H3>
<FORM NAME="regForm" ACTION="regcheck.asp" METHOD="POST" onSubmit="return
     checkValues()">
Name: <INPUT TYPE="TEXT" NAME="Name" maxlength="25">
<P>
Address: <INPUT TYPE="TEXT" NAME="userAdd" maxlength="50">
<P>
Login: <INPUT TYPE="TEXT" NAME="userlogin" maxlength=“20">
<P>
Password: <INPUT TYPE="Password" NAME="userPassword" maxlength="15">
<P>
Confirm Password:<INPUT TYPE="Password" NAME="conPassword" maxlength="15">
<P>
Email: <INPUT TYPE="TEXT" NAME="email" maxlength="15">
<P>
<INPUT TYPE="submit" NAME="Go" VALUE="Register!">
<INPUT TYPE="RESET" VALUE="Reset!">
</FORM>
</BODY>                                                                      12
</HTML>
13
14
15
16
17
18
Extensible Markup Language (XML)
   World Wide Web Consortium (W3C) – non-profit
    organizations that maintains standards for the web
    presented the draft of XML in late 1990’s
   Inlcudes data management capabilities that HTML
    cannot provide
   Consider example of a list of planets
       Same HTML tags are decided to be used for information of each
        planet – actual list can be longer- nine planets
       Explain the HTML code
       Show the browser result
       Shortcoming of HTML – only 6 levels of headings – problem if
        each planet item has more information elements like color or
        size of planet
       In late 1990’s web professionals considered XML as a list
        formatting alternative of
                                                                    19
<HTML>
<HEAD>
<TITLE>Planets</TITLE>
</HEAD>
<BODY>
<h1>Planets</h1>

<h2>PlanetName</h2>
<h3>DistanceFromSun</h3>
<h4>Moons</h4>
<h5>DayLength</h5>

<h2>Mercury</h2>
<h3>36 million miles</h3>
<h4>None</h4>
<h5>176 Days</h5>

<h2>Venus</h2>
<h3>67 million miles</h3>
<h4>None</h4>
<h5>117 days</h5>

<h2>Earth</h2>
<h3>93 million miles</h3>
<h4>One</h4>
<h5>24 Hours</h5>
</BODY>
</HTML>
                            20
21
   XML differs from HTML in two important
    respects
       XML not a markup language with defined
        tags- can create own set of tags -<address>
       Tags do not provide information how text
        would appear on a web page, rather tags
        convey meaning of information included
        within them-tags define the meaning of facts
   To understand distinction consider the
    example of planets again – XML code for it



                                                       22
<?xml version=“1.0”?>

<PlanetsList>

<Planet Name=“Mercury”>
<Distance>36 million miles</Distance>
<Moons>None</Moons>
<DayLength>176 days</DayLength>
</Planet>

<Planet Name=“Venus”>
<Distance>67 million miles</Distance>
<Moons>None</Moons>
<DayLength>117 days</DayLength>
</Planet>

<Planet Name=“Earth”>
<Distance>93 million miles</Distance>
<Moons>One</Moons>
<DayLength>24 Hours</DayLength>
</Planet>

</PlanetsList>


                                        23
   First line of code – declaration – version 1
   Root element tags – 2nd & last line – contains other
    elements – assigned a name that describes purpose of
    file
   Other elements are child elements – country is child
    element of countrylist – each attribute is child element of
    country element
   Names of child elements can be different between two
    organizations- how share information – capital or
    capitalcity
   Many companies have agreed to follow common
    standards for XML tags – these standards in the form of
    data type definitions (DTDs) or XML schemas are
    available for different industries – accounting
    information, legal information standards etc.
   In 2001 W3C released a set of rules for XML documents

                                                             24
                XML has its rules!
   All elements must be properly nested
       <outer><inner>content</inner></outer>
   All attribute values must be quoted
       <FRIES SIZE=“LARGE”>
   All elements with empty content must be
    identified by ending in />
       <BR/>
   All elements must be cased consistently
       <PART> must not be closed as </part>
   Certain characters having reserved meanings
    cannot be used
       &,<                                       25
   Embedding XML into HTML documents
       <XML> element can be used anywhere within
        HTML document to enclose XML content -
        </XML>
       <script> element can also be used




                                                26
<html>
<head>
<title>XML-example</title>
</head>
<body>
<h1>HTML text here</h1>
<xml>
<meal>
<burger>
<name>spicy</name>
</burger>
</meal>
</xml>
</body>
</html>                      27
<script language=“xml” type=“text/xml”>
<weather>
<rainy/>
</weather>
</script>




                                          28
   Basic way to render XML is to translate it into
    html – server side program translates xml
    documents to html documents at delivery time
   We write XSL rules that match various xml
    elements and output the appropriate html
   XML files are translated using another file which
    contains formatting instructions
   Formatting instructions are often written in
    Extensible Stylesheet Language (XSL)
   These formatting instructions are read over by
    special programs – usually these programs are
    written in Java programming language- called
    XML Parsers
   Diagram how web server might process http
    request for an XML page – explain it
                                                        29
                                             2        Web server
1    A web client                                     requests an
     sends an HTTP                                    XML document
     request for an                                   from the XML
     XML document                                     database

                                                    The XML parser
                      Web Server                    program, which
            6                                       can run on the
     The web                           XML Database XML database
PC
     server           The XML                       server or on the
     delivers the     parser sends                  Web server,
                      the newly                     formats the data
     document to
     the client       formatted XML             3 using a style
                                                    sheet
                      document to
                      the web server

                         5
                                          XML
                                         parser

                          XSL style
                            sheet                 4
                                                               30
<?xml version=“1.0”?>
<?xml-stylesheet href=“catalog.xsl” type=“text/xsl” ?>
<CATALOG>
   <PART>
        <NAME>Switch</NAME>
        <DESCRIPTION>A very efficient device</DESCRIPTION>
        <PRICE>Rs. 1000</PRICE>
   </PART>
   <PART>……</PART>
    ….
</CATALOG>
</xml>




                                                             31
<?xml version=“1.0”?>
<xsl>
<rule>
    <root />
    <html>
    <body bgcolor=yellow>
    <children />
    </body>
    </html>
</rule>
<rule>
    <target-element type=“PART” />
    <DIV style=“margin-bottom:20px”>
    <children />
    </DIV>
</rule>
<rule>
    <element type=“PART”>
    <target-element type=“NAME” />
    </element>
<B>
<children />
<B>
<BR />
</rule>
………
</xsl>
                                       32
          HTML and XML Editors
   General purpose text-editors, Notepad etc.
   HTML editors available help create web pages more
    easily
   Web site design and creation programs or web page
    builder softwares – result in one window and code in
    another
   Edit in one window and the result is reflected in other
   Drag and drop images on web browser view page and
    program automatically generates HTML tags to position
    it
   Macromedia Dreamweaver generates the HTML brackets
    automatically
   Microsoft FrontPage
   Xml also in any text editor – programs include Epic
    Editor, TurboXML – tag validation and editing job
    becomes easy
                                                          33
                Web Server

   A computer that delivers (serves up) web
    pages with an IP address and possibly a
    domain.
   Any computer can be turned into a Web
    server by installing server software and
    connecting the machine to the internet.



                                               34
              Introduction to ASP
   ASP – Active Server Pages
       Used to create web sites that provide user with
        individualized data, Access to file system and
        databases and much more…
   Runs best on IIS - Internet Information Server
   IIS is available free with windows NT option
    pack and more popular Windows 2000
   ASP engine works with any scripting language
    (that is compatible with Microsoft Scripting Host
    requirements) but VBscript is most popular and
    recommended

                                                          35
                Intrinsic Objects
   To use most objects from a programming language, you
    must first create an instance of the object you want to
    use. An object instance is a single copy of an object. You
    create an instance of an object by creating an object
    variable, then assigning a new copy of an object to the
    variable. The process is called instantiation.
   You don’t have to instantiate ASP objects. The seven
    objects that ASP exposes are called intrinsic objects
    because you don’t have to create them. They are always
    available for you to use on any ASP page.



                                                            36
         Intrinsic Objects of ASP
   Response Object : Used to send information to the client
   Request Object : Used to retrieve information included
    with the request from the client
   Server Object : Used to communicate with the server
   Application Object : Used to store (cache) information
    about you application
   Session Object : Used to cache information about a
    specific browser instance ( which usually, but not always
    corresponds to a single user)
   ObjectContext Object
   ASPError Object

                                                            37
                Variables in VBscript
   VBSript has only one type of variables – the Variant type, but it can
    hold any of three kind of values:
        scalar values (meaning Boolean, Integer, long, Single, double, Date,
         curreny, String)
        Arrays
        object pointers
   To create a scalar variable, you define varialbe using Dim
    statement, then you assign values to the variable
         Dim x
         x=100
   VBscript by default assumes that any symbol that is not a keyword
    is a variable. This might cause serious problems when you are
    writing an ASP application. What if you mistype a variable name and
    it will be considered by the server as a new variable. To avoid this
    you must write Option Explicit at top of your each ASP file


                                                                                38
                    Response
   When a browser requests data from the server, the
    server responds, either with a redirect message, the
    requested data, or an error message.
   For HTML requests, the response data comes directly
    from the Web server, which reads and returns the
    content of an HTML page. For ASP pages, the response
    data comes from the ASP object called the response
    object.
   The process the web server uses to return a response
    might be complex but returning a response using a
    response object couldn’t be easier.

                                                           39
<%@ language=VBScript %>
<%option explicit%>
<%Dim lastname
Dim firstname
Dim myage
lastname=“abc”
firstname=“xyz”
myage=30
%>
<html>
<head><title>It is easy</title></head>
<body>
My name is <%=firstname%> <%=lastName%> and my age is
    <%Response.Write myage%>
</body>
</html>




                                                        40
             Response.Write

   This function of response object can be
    used to write anything you like on the
    server side, to create dynamic contents of
    a web page (even HTML).
   The Write method accepts a text string.
   You must surround the text with double
    quotes

                                             41
      More of Response Object
Response Object is not restricted to write function
  only it has much more to it.
 Response.Redirect: to redirect the page on
  submission or otherwise. Like
  Reponse.Redirect http://vu.pk.edu
 Response.Expires property when set tells the
  browser when it need to reload the page for
  example
  Response.Expire=10 in a page will tell the
  browser to reload the page after 10 minutes
  have passed

                                                  42
        Request.Form Collection
   The Request object contains information that
    the browser sends to the server.
   The request Object offers five different collection
    of information one of them is Form which
    contains information user enters into input
    controls and information your application has
    stored in form variables
   When a browser submits form data using post
    method, the ASP engine parses the raw HTTP
    form data and stores it in the Request.Form
    collection

                                                     43
<FORM NAME="regForm" ACTION="regcheck.asp" METHOD="POST"
   onSubmit="return checkValues()">
Name: <INPUT TYPE="TEXT" NAME="userName" maxlength="25">
<P>
Address: <INPUT TYPE="TEXT" NAME="userAdd" maxlength="50">
<P>
Login: <INPUT TYPE="TEXT" NAME="userlogin" maxlength="15">
<P>
Password: <INPUT TYPE="Password" NAME="userPassword"
   maxlength="15">
<P>
Confirm Password:<INPUT TYPE="Password" NAME="conPassword"
   maxlength="15">
<P>
Email: <INPUT TYPE="TEXT" NAME="email" maxlength="15">
<P>
<INPUT TYPE="submit" NAME="Go" VALUE="Register!">
<INPUT TYPE="RESET" VALUE="Reset!">
</FORM>


                                                             44
Request .Form(“userlogin”) will give you what user has typed in userlogin text
   box.
Userlogin is the key for request.Form collection to retreive information
For example (let it be regcheck.asp)

<%@ language=VBScript %>
<%option explicit%>
<%Dim loginname
Dim name
loginname=Request.Form(“userlogin”)
name=Request.Form(“username)
%>
<html>
<head><title>It is easy</title></head>
<body>
My name is <%Response.Write name%> and I am going to use
<%Response.Write loginname%> as my login
</body>
</html>



                                                                            45
        Using other programming
               operatives
   VB script offers a lot of flexibility to
    program
   If statements
   Loops
   Many functions to handle your strings
   Much more…


                                               46
<%@Language=“VBSCRIPT”%>
<%option explicit%>
<HTML>
<Body>
Test1
<%
Dim myString=“ecommerce”
%>
<%If Time>=#12:00 AM# and Time<=#12:00 PM# then%>
<h3>Good Morning Pakistan</h3>
<%else%>
<h3>Hello Everyone <p>
<%
Dim j
For j=1 to 3
   response.write myString
   response.write “<p>”
Next
%></h3>
<% end if %>
</Body>
</HTML>
                                                    47
48

				
DOCUMENT INFO
Description: E-Commerece