Вы находитесь на странице: 1из 379

|  

Day 
| 

‡HTML stands for yper ext arkup


anguage
‡An HTML file is a text file containing small
  
‡The markup tags tell the Web browser  
 the page
‡An HTML file must have an  or   file
extension
‡An HTML file can be created using a  
 



‡HTML tags are used to mark-up HTML  


‡HTML tags are surrounded by the       

‡The surrounding characters are called    
‡HTML tags normally      like <b> and </b>
‡The first tag in a pair is the    the second tag is the
 
‡The text between the start and end tags is the  

‡HTML tags are    <b> means the same
as <B>This is an example of <b>bold</b> text
á  



÷÷ ÷  




  „     
 „ 

     
  
   ÷ 
  
 

     
 
   ÷ 
  

- ÷÷ ÷÷   


   ÷   
      ÷÷  
  
 

  


á  

 


    ÷÷
  


 ÷

<html>
<head>
<!-- This section is for the title
and technical info of the page. -->
<Title>This is a Title </Title>
</head>
<body>
<!-- This section is for all that
you want to show on the page. -->
This is a Body
</body>
</html>
á  

 
a
| a    

   
á  

     ÷
÷÷ 
  
  

  ÷  


÷  

ð    ð   


 
÷   ÷ 
÷
 

   
    

÷

     ÷÷  


  
  
  

  

   
    
 

  


    
    
 !    

  ÷   ÷"# 


- ÷÷  
    
 
 
÷


$%!!&%!!
     '  (  ÷ 
)


Ä  
     
÷÷    
   

÷
  

]  
 
   ÷  ÷    ÷ ÷÷   


"# ÷ 

*
+
(
#
#

# 

 ÷ ÷ 

  
  


Ä  
] 

]
  
$,]*   ) &
-  ÷     
.   

%÷

] 

*  ] 

/ ÷

/ *

/ *

/   

" ÷ %÷

u am  m
<"#
"0-1
]#0* 
2 3]#0
3"0-1
.415
"6%  
 %÷ ÷ 3"6
           ÷ ÷ 
  %  
 ÷ ÷ 

 ÷ ÷   7 
3.415
3"#

]  a u am  y a  may a 



uD]u DY a 
  u am  m
 

Œm  a a y   
y a Var
y  
 r a r
 a 

 a
 a

-r am    
 a ara ra 
    a  a  
y   r

 a ara ra   a
      mar
 r
 mar
 r
  r   a    m mr a  
 
  r r m
r a   a
m  a rma
 

   ! r
   rma 
a r
 

" #$$a
      
„
ÄÄ ma  
   
a


 r
 r 


  r
  
Ä Ä  ar
 ma
 
 
   a  
% a r

a r
 ar
"Œ]u#$$  a 
% & r  ' r r a
 (
")  *#$$  a  r  
"-)u#$$   y
    y &r m a (
  „
<HTML>
<HEAD><TITLE> EXAMPLE 2</TITLE></HEAD>
<BODY>
<B> This line is BOLD</B><BR>
<U> This line is UNDERLINED</U><BR>
<I> This line is ITALICS</I><BR>
<S> Text is STRIKED</S><BR>
This line is normal<BR>
<BIG>The font of this line is BIG</BIG><BR>
<SMALL>The font of this line is
small</SMALL><BR>
<DIV ALIGN="CENTER">
This line is aligned <B>centre</B>
</DIV>
  „ 
<DIV ALIGN="LEFT">
This line is aligned <B>left</B>
</DIV>
<DIV ALIGN="RIGHT">
This line is aligned <B>right</B>
</DIV>
<FONT SIZE="+5" COLOR="RED" FACE="NEW TIMES ROMAN">
Doeacc <U>Centre</U> Chandigarh
</FONT>
<FONT SIZE="+3" COLOR="BLUE" FACE="ARIAL">
<BR> Doeacc<I>Centre</I> Chandigarh
</FONT>
</BODY>
</HTML>
  u am + m


 r ar  r  y 

    
 ]
a  a  r r  
a ar 
  a a 

  a  ,m r a 
 r a a ar a ma
ay a a   a
a  
r 


  

Ä   
 ] a  a r r  

  
 
 a a  


 ]  - 
 a r r  
  a   a ar a a  
a
 a  m r 




 
 
 rm a 
r m a

a  a  


 

ar

  D a  
 .D  D a 
 r  a rm 
  
  
 a DD a
 r  a  


 
 r a a

  a
 a ar a ma
ay
   

 a r r  r m r  

a r
 ar
"Y u # $$  y  m ra    a   
 
 a ar a]

"Œ* # $$  a 
 
  ar 




 a r r  r   

"Y u#$$      mar 

m 
 a ar D]Œ) )]*)u a
Π*u
  a 

m r  
  r 

"Y u#$$  y   r m r    a  

m 
 a ar
D]Œ) )]*)u
" Π*u  a ]
 
"Vu#$$  m r
 a 


m  a &a  

m a a
 

   
(
   a  


 

  a  


 rm a a ar   


 

   rr 
  


  a  


 rm a a ar   


 

  „

<HTML>
<HEAD><TITLE>list test</TITLE></HEAD>
<BODY>
Computer Languages
<UL type="circle">
<LI>BASIC <LI>C <LI>C++ <LI>Pascal <LI> Fortran
</UL>
Measurement Units
<OL>
<li>Bit <li>Kb <li>Mb <li>Gb
</OL>
</BODY>
</HTML>
  u am / m
u am 0 m
<HTML>
<HEAD><TITLE>Example 4</TITLE></HEAD>
<BODY>
<B>Input/Output devices</B>
<OL>
<LI>Keyboard
<LI>Printer
</OL>
<DL>
<DT><U>Keyboard</U>
<DD>Keyboard is an input device.
<DT><U>Printer</U>
<DD>Printer is an output device it can print 1400 lines
per minute.
</DL>
</BODY>
</HTML>
  u am 0 m
D
 r   y  r r 
u am
 my0,m r 
.0


 .


aaa .


 m .


 ra .
.
0 r 
.0 y #$$

 .


aaa .


 m .


 ra .
.
0 ra  r 
.0 y #$a$

 .


aaa .


 m .


 ra .
.
0*mam r 
.0 y #$]$
 .


aaa .


 m .


 ra .
.
0 ra *mam r 
.0 y #$
$

 .

aaa .

 m .


 ra .

..y. m
   r r 
u am
ra
 Œ
1

2 )r a r r  a r r  
r 
 r 
m
 yr r  u    ) ] r a
|  D

 

2 )r a a ,  r r  .  r r  
r 


  r  u    ) &
 ) r 
ar Π|
  Π|r Πu   (
ŒmmaryDay!
/ 8 
 "#
/ "#

/ "# 2-,0!+9%9+0
/ "0-1!0%]4:
/ .415!0%]4:
/  * 

/ #

/ 4#

/ 9 4#

/ 0÷
 1  

/ 2 !

 
Day+
a )
 1
á  r
% a r r  ara 
    a
a r

ar
"],#$$ r a  ra
m  
&u-)u,u**]3Œ]-]uD(
", ŒDu#$$ 
ay a r r a a 
 r
"Œ]u#$$
%   r r
"|]D#$$ 
    r r
Ä  
 r a
  
 a ara ra
"],#$$ r a
m  &u-)u,u**]3Œ]-Y(
   
ay r rma 
"|]D#$$ 
    rma 

Ä
Ä r a  r



 r a  r r

u am 4 m
<HTML>
<HEAD><TITLE>Example 5</TITLE></HEAD>
<BODY>
<H3 ALIGN="CENTER"> Test of different HTML tags</H3>
<HR ALIGN="CENTER">
Quadratic equation :
<B>A<SUP>2</SUP>+B<SUP>2</SUP>=A<SUP>2</SUP>
+B<SUP>2</SUP>+2AB</B>
<P>
Chemical Equation :
<B>H<SUB>2</SUB>+O=H<SUB>2</SUB>O
<P> Quadratic equation tells us the formula of algebra.
Chemical equation shows one chemical reaction <P>
<PRE>
Quadratic equation tells us the formula of algebra.
Chemical equation shows one chemical reaction
</PRE>
</BODY>
</HTML>
  u am 4 m
á 

  m 
 a   r
 m  a 
  a  r
a
  am m  r  a 
r y 
 r 
m  
|  y 
   y r
    

y r
 ar  m 
a
 r 
  a
y r y m 

  |r |
 | 
 

    ÷ 
    
3
  ÷÷
  ÷ 
÷
    3
  
  ÷   

u    
   ÷÷  
 ÷ 
y y r




    r |  a

 

 a a

  a  

ar a  ra
u!ma
 



    ra
 y r 
 ar   r
  r a a
y rm  |  a  a  r   y 
  m

 yr m 
] yr  
a  ra a  y    r


 rm      r  a  r a 

a 
 
 a r $ar$
a   
 


  
 
 a ar
a r
 ar
",u#$$  
 a ar
"*u-#$$  *   
  r r
"*u#$$  rm
  r  r r 
  
ay 
u am 5 m
<HTML>
<HEAD><TITLE>RCC - Example 6</TITLE></HEAD>
<BODY>
<H2 ALIGN="CENTER">Doeacc Centre
Chandigarh</H2>
<HR ALING="CENTER" width="300">
<DIV ALIGN="CENTER"> Doeacc Centre Chandigarh a
setup of National Informatics Centre, Planning
Commission, govt. of India was set up in 1978 to
promote use of computers. It is one of the pioneer
computer centre of this country. </DIV>
<P>
<A HREF="HEAD.HTML">Head Office</A><BR>
<A HREF="BRANCH.HTML">Branch Office</A><BR>
<A HREF="ACHIEVE.HTML">ACHIEVEMENTS</A>
</BODY>
</HTML>
  u am 5 m

 

aa
 y r
    a  r a 
     a


  y     am a  a r a r  -m   

 r  ar  a
  a 
-r u am ! y  a a    a    a r  a 
 a 
 m  a a a r r y   

  
]
a 
 r  ay    . ar a

 a am   



   a  r  a r

 á    

  ym m a a  r $$ r  r  a am  ar 


 

 
rr  m   ra  r a a ara a      r a r 
  | 
r r 
 
ay  ar   a ar
 
   ,u#$6$ a
u am ' m
<"#
"0-1]#0140-%% %0:+0 0÷
;3]#03"0-1
.415
"6 -#],:<=%0:0+=140-%% % 3"6
"+ 8]1"<=>??= ÷ <=%0:0+=
- :-0<=42=3-
140-%% %  %   
 
  ÷ 
  %  

 %÷   ÷ 
 ÷    
    


.+
- "+0*<=@! =!  

3- AA
- "+0*<=@# =#  

3- AA
- "+0*<=@%=%  

3-
"+
- :-0<=! =3-
) 1
<U>Short term courses</U><BR>
DOEACC CENTRE Chandigarh offers following short-
term courses
<OL>
<LI> Use of Personal Computer
<LI>'C' Language
<LI>'C++" Language
<LI>Visual Basic
<LI>Oracle/Dev. 2000
<LI> AutoCAD
<LI> Internet and Web Designing
</OL>
<A HREF="#Top">Back</A><P>
<A NAME="Long"></A>
<U>Long term courses</U><BR>
DOEACC CENTRE Chandigarh offers following long-term courses
) 1
<OL>
<LI> P.G.D.C.A
<LI> O¶ Level
<LI> A¶ Level
<LI> B¶ Level
<LI> C¶ Level
</OL>
<A HREF="#Top">Back</A><P>
<A NAME="Cor"></A>
<U>Corporate courses</U><BR>
DOEACC CENTRE Chandigarh offers following corporate
courses
<OL>
<LI>Use of Personal Computer
<LI>Courses according to their requirement
</OL>
<A HREF="#Top">Back</A><P>
</BODY>
</HTML>
  u am ' m

  a  

ar a  ra
] y a  
 yr rr    a     r ar
 a  r   a 
a

y
a  r
  y

-r  am y 
  ar r am 
a   a   y  a  ar am 
-r u am 

á á „„   

 y
  $Œr  rmr $
    
 a am $ŒuVu,$am 
r  y 
 
  r ,u#$Œr $.a ar
u am 7 m
<HTML>
<HEAD><TITLE>DOEACC CENTRE - Example
8</TITLE></HEAD>
<BODY>
This example shows you how to make link
to the other web page.<BR>
<A HREF="SEVEN.HTM#Short">Short term
courses</A><BR>
<A HREF="SEVEN.HTM#Long">Long term
courses</A><BR>
<A HREF="SEVEN.HTM#Edu">Corporate
courses</A>
</BODY>
  u am 7 m
u!ma


] a

  

    a a    ar 
 
a  . a a y  
 yr !ma
 ar  


m ay  a r a r  yr |  a  a a
 y

á  
„
 „ 
 
„
 „ 
 

 a 
 
    r' !ma
 ar  |  ay  r

  $
ma8 ma
m$   a 
 a ar 
r 
 
  r y a m a r a 
r r a 
 

mm 
a y     r
u am 9 m
"#"0-1]#0140-%%%0:+0 0÷B
3]#03"0-1
.415
"6-#],:<=%0:0+=*4:%4#4+<=.#90=% .

! 3*4:3"6
"+-#],:<=%0:0+=8]1"<=C??=
% .
! 
    ÷   

 ÷÷    
 

   
÷ 
 ÷
5       ÷-
"+0*< ÷   D  ÷  
  D  ÷ 3-.+÷ 
    
  ÷  ÷÷ E>

.+"6-#],:<=%0:0+=*4:
%4#4+<=.#90= 
3*4:3"6
3.415
3"#
  u am 9 m
ra
 Œ
1
)r a a, 
| 

y r
  a

m   rr 
  
Π 
   


    

 
u 
2 a

 Œ

2 Ya& ..yam(
2 * 

2 ]
a
m
2 Πaru

2   & ..   m(
2 Ya
2  aV
a
ŒmmaryDay!+
2 a )
 
2 y r

2 y y r

2 

    ra 
2 
 

aa 
2 
  a  

ar a  ra 
2 u!ma

 
2 u am D
 r  
 
2 ra
 Œ
1
Day/
ra
 !a ra r
 ma a 
 a r a r  yr 
  
 
y  a r r r a a a r y a 
  
 


Ä Ä    y & a a (  


 m 
a r
 ar
"Ä  
 #$$ am r  ar  
ma 
   a
a r
"Ä  #$$  r   a a r
"  #$$  r   a '
" #$$  r  a
a  

" #$$  r    

" #$$  r    

u am : m

uD]uD u)))u,*u! u am :.]u.uD
 DY)  *#$
 y $u#$mar$],;#$ay$
V],;#$r $],;#$ r $
],#$)u,u*$D u)))  r .
*|]D#$0::$a
#$)u,u*$
 D u)))  r )a
ar r may r  rm  rm
 a
ar )
  
 
  
ya  
mr a r * 
*u-#$6Œr $Œr  rmr . 
*u-#$6 $  rmr . 
*u-#$6)r$)rra r . 
*
. DY
.
  u am : m
)
a ]ma
|  a   a ma  
   am
a a ma ay
ma
  a 
a 
  a  r a  

r ] 
  y  
 a
ma
    a  

 

        a
  
 a
ma
  m 
a r

ar
" Œ*)#$$  ar  
ma
"#$$ a ra
  
ay
"],#$$  r a   r a
m  &u- )u,u* *] 3Œ]-Y(
"u]#$$ 
  
ma
"|]D#$$ 
   
ma
" *Du*#$$ r r 
 
"Π)u#$$  r
% a a ara
 
ma rm   r  
"VΠ)u#$$   r
a a ara
 
ma rm   r  
"Œu #$$ am  
ma ma  

a
   
   <
*u
   „
<HTML>
<HEAD><TITLE>DOEACC CENTRE ± Example 11</TITLE></HEAD>
<BODY BGCOLOR="YELLOW">
<H2 ALIGN="CENTER"><FONT COLOR="BLUE">Computer Books Store</FONT></H2>
<HR ALIGN="CENTER" WIDTH="300">
<PRE>
The Computer Books Store has now come to your city a large variety of
books
available on different topics. Just step in and find yourself in the new
world of books. You can contact me at

e-mail:<A HREF="mailto:buddhiman@hotmail.com">
buddhiman@hotmail.com</A>
</PRE>
click the button for the listing of books available.
<A HREF="BOOKLIST.HTML">
<IMG SRC="BOOK.BMP" BORDER="NONE" ALT="CLICK ME" ALIGN="CENTER"></A>
<BR>
place your orders on internet and the delivery will be in 24 hours.

<H2 ALIGN="CENTER"><FONT COLOR="BLUE">Thanks</FONT></H2>


</BODY>
</HTML>
  u am  m
u am + m
<HTML>
<HEAD><TITLE>DOEACC CENTRE - Example 12</TITLE></HEAD>
<BODY BGCOLOR="YELLOW">
<H2 ALIGN="CENTER">Pictures</H2>
<IMG SRC="ONE.BMP" ALIGN="LEFT" BORDER=1 HSPACE=20
VSPACE=5><BR>
<DIV ALIGN="LEFT">This is picture 1</DIV><BR>
<BR>
<BR>
<IMG SRC="TWO.BMP" ALIGN="RIGHT" BORDER=1 HSPACE=20
VSPACE=0>
<DIV ALIGN="LEFT">This is picture 2</DIV>
</BODY>
</HTML>
  u am + m
ra
a
 <]ma a 
] 

  
  

 a
ma
 
r
 a 
  
 r  m    m 

  

a  a
  a ay
ma a 
ma
  a
ma ma 

 ma ay y 
ma ma y 
    
r
  m r
a 
 !r
a  a r
 



ma a y a   
a 
 y a 


 a
 r    ay
ma
 a
 r  a
a   !r
a a   m   r   
y a  m  
ma  !r
a a 
 m   r      Y 


ra
a
 <]ma a  1
 ma  r
  ay
ma    a
  a    r

    a

   
   
 ar a  m  a r a a
ma
ma
a r
 ar
,u#$$  am  
ma ma   r a 
  
    
 
 a ar

a r
 ar
Πu#$$ a y   

ma ma 
  
 
a &Du- *u) Y(
) *DŒ#$$ 
%   a 
 

*u-#$$  *   
  r r
u am / m
<HTML>
<HEAD><TITLE>TEST OF MAP REGION</TITLE></HEAD>
<BODY BGCOLOR="YELLOW">
<MAP NAME="RECT-CIR">
<AREA SHAPE="RECT" COORDS="0,0,110,50" HREF="RECT1.HTM">
<AREA SHAPE="RECT" COORDS="130,0,243,50" HREF="RECT2.HTM">
<AREA SHAPE="RECT" COORDS="0,70,110,120" HREF="RECT3.HTM">
<AREA SHAPE="RECT" COORDS="130,70,243,120" HREF="RECT4.HTM">
<AREA SHAPE="CIRCLE" COORDS="110,50,130,70" HREF="CIRC.HTM">
</MAP>
<DIV ALIGN="CENTER">
THIS IS A TEST OF MAPING REGION OF AN IMAGE.<DIV>
<P>
<IMG SRC="MAP-REG.BMP" USEMAP="#RECT-CIR" BORDER=0
ALT="CLICKABLE IMAGE">
<P>
<DIV ALIGN="CENTER">JUST FOR FUN.<DIV>
</BODY>
</HTML>
  u am / m
 
   m  r  r r a
   a 
 
a  
 a   arra a ra

  m

m a r 
 r  
  ar   
  a a    r 
a
  ay a a ara   a y r a   ma
a y a  ar 
  Ä Ä a 
  
u 
  

-.#0  
 ÷ "#] .4+10+   

 
3-.#0 

÷
  ÷ 

%-2]4:  
      ÷  ÷÷ 
  
3%-2]4: ÷
       ÷   -#],:<.44
 
 
     ÷  ÷V u-  
    
     

+3+
  
 ÷   ÷5 ÷    

 -#],:$#0*%0:0++],"& 3F-#],:$42
]11#0.44&!÷-   
    
 ÷
   

"3"  
 ÷ ÷÷.÷      
 ÷÷
÷ 
 ÷ ÷÷
       
   
  

  ÷÷ 3
  
!÷-   
 
  
 ÷   

131  
 ÷  ÷÷.÷      
 ÷÷
÷ ÷  
  ÷÷÷  ÷÷
       
 
     

  ÷÷ 3
  
!÷
-   
    
 ÷   
 
 
  r
  
 

.rD.D  
 rr
    a a
m   
a*.*

-    1
  

-#],:$#0*%0:0+ " ( ÷÷   ÷÷


+],"&
F-#],:$42]11#0 F ÷÷   ÷÷
.44&
%4#!2-:<›  $›& ÷

÷÷



+48!2-:<›  $›&


 ÷÷




:48+-2     


÷÷
a   am
Ñ  

" ÷÷  
3"  
 ÷÷ 6$&
" ÷÷  
3" ÷
 ÷÷ 6$&
3+   
 
+
 
   
1 ÷÷  
31  
 ÷÷ E
1 ÷÷  
31 ÷
 ÷÷ E
3+  
   
+
 ÷
 
1 ÷÷  
31  
 ÷÷ ÷

1 ÷÷  
31 ÷
 ÷÷ ÷

3+  ÷
 
3-.#0   ÷ 
ra
 Œ
1

2 
  a a r r  a
y r
 r  

2 ] r a ]ma a a r   a 
2 ] r  )may  
ma
    r  
a 
2 Π
ma
 
 r 
%   am
 a 
2 a a y r
  
ma 
ŒmmaryDay!/
2 ra
 !a ra r 
2 ]ma 
2 )
a ]ma
2 ra
a
 <]ma a 
2 a ] r

2 u am D
 r  

2 ra
 Œ
1
Day0
 Ä Ä
)r a a a a a  a
 ay m r  r
a r
 ar 
 *Du*#$$

a  
 
 
   a r r 
)uΠ)],#$$  am  a      
  a 
)u DD],#$$  am  a          a

  
|]D#$$  
    a   a 

 r a 
 a r a
a  r  a  a

 
)  *#$$ a r r  a  
  a a    a
 
r
 a r a
 r a r
 
);* ,D#$$ a r
ma 
 

 a  
  a a
   a
 
r 
a r a  r a r
 
    
 a a r
D 
 a a r  a

  r mr  
a r
 ar

],#$$  r
% a a
m         


 
r 
 a ar u- *] )u,u*
V],#$$   r
a a
m         


 
r 
 a ar   ]DDu a   
)  *#$$ a r r  a  
  a a 
  a
 
r  a r a  r a r
 
);* ,D#$$ a r
ma 
 

 a  

 a a    a
 
r  a r a  r
a r
 
    
 a a a a 
],#$$  r
% a a
m      
    
 a ar u- *] )u,u*
V],#$$   r
a a
m       
   
 a ar   ]DDu a   
* |Π,#$$  m r  r 
  
 a
) Π,#$$  m r  m 
  
 a
|]D#$$  
    m   

 r
a 
 a r a a  r  a  a 
 
)  *#$$ a r r    
);* ,D#$$ a r
ma 
 
 
 
 á á  
 a a  a
  
a r
 ar
],#$$  r
% a a
m      
    
 a ar u- *] )u,u*
V],#$$   r
a a
m       
   
 a ar   ]DDu a   
* |Π,#$$  m r  r 
  
 a
) Π,#$$  m r  m 
  
 a
|]D#$$  
    m   

 r
a 
 a r a a  r  a  a 
 
)  *#$$ a r r    
);* ,D#$$ a r
ma 
 
 
 
u am 0 m
<HTML>
<HEAD><TITLE>DOEACC CENTRE - Example 14</TITLE></HEAD>
<BODY>
<DIV ALIGN="CENTER">
<B>Time Table</B>
<P>
<TABLE BORDER=2 CELLPADDING=5 CELLSPACING=5>
<TR><TH>City<TH>Distance<TH>Fair
<TR><TD>Bhopal<TD>500 k.m.<TD>Rs/- 200.00
<TR><TD>Delhi<TD>450 k.m.<TD>Rs/- 175.00
<TR><TD>Chandigarh<TD>750 k.m.<TD>Rs/- 300.00
<TR><TD>Kanpur<TD>75 k.m.<TD>Rs/- 25.00
</TABLE>
</DIV>
</BODY>
</HTML>
  u am 0 m
  !„
<HTML>
<HEAD><TITLE>DOEACC CENTRE - Example 15</TITLE></HEAD>
<BODY>
<DIV ALIGN="CENTER">
<B>Formula Table</B>
<P>
<TABLE BORDER=2 CELLPADDING=5>
<TR><TH> Shapes <TH> Name<TH>Formula
<TR ALIGN="CENTER"> <TD> <IMG SRC="TRIANGLE.BMP"> <TD>
Triangle <TD>(Height * Base)/2
<TR ALIGN="CENTER"> <TD> <IMG SRC="CIRCLE.BMP"> <TD>
Circle <TD>Pi * r<SUP>2</SUP>
<TR ALIGN="CENTER"> <TD> <IMG SRC="SQUARE.BMP">
<TD>Square<TD>Side<SUP>2</SUP>
</TABLE>
</BODY>
</HTML>
  u am 4 m

  a 
 a u am
 my a r r#$$
 r 

aara ra.


a  rara ra.. 
 
  a
 a a 
 a r r#$$ r .  . . r r
 ).  D. . r. a 
. . r
 r
 
  a
 a



a .


aaa .



 a .

.
. 
 u . 
. r
. a .y. m
  ! 
  a 
 a u am
ra
 Œ
1
)r a aa yr a

a
D a
 u 
a 

 )m 
")a
"Œ.) ,am
"ar.
 r
y,am
"Y ar a

" r  a .ra  
ŒmmaryDay!0
2 u.u
2 *.* 
 a a r
2 D.D 
 a a a a 
2 . 
 a a  a
  

a r
 ar 

2 u am D
 r  

2 ra
 Œ
1
Day4
-rm 

-rm ar     


rma
rm    
r ar a 
 rma   r 
  ar r r  r

rma
rm  r a r r a 
u ryrm

     a 
| 
a   m   r  a 
 
"  

"   
"  a
"      a  r 
  
-rm 
  

  

a a
 rm

a r
 ar 

 #$$ ar   r
  r 
rm


 á #$$  rm
 
      
r rrmay   ra  r a
 
 

 
 
 a
  m  r a rm
a r
 ar 

#$$  y r 

 
  
 a ar )u); 
*D]  *uŒu Œ] -]u a u
#$$  am  

m a a    r


#$$ r a
m   a a = r a   r ra

   a   m
 
  rm= r r r m
  
 a  r   

 #$$  r 
 r a
ma &  ( r   a ra

  

a a 

m
  
 "#$$  
 
 ara r   a
 r

 á#$$  ma
mm m r  ara r a a   r 

  a r

 #$$   r
ma 
a

  

   r a a m  r r


 

 

m
a r
 ar

#$$  am a
a    r

 "#$$  m r   m   
ay ] Œ]u


a    
  m a r
 

]  Œ]u

    

 m 

 $$ a m
  
 rm a 

 

 

a a 

m 

 a
   m 

#  $ 
 
a r

  
  
     y  a
  


#$$  a  m

 
 

      rm
m

      

      

a am

 
  ryrm  m  D a  a 
 

a r
 ar

#$$  am   a    r

%#$$  m r  r 
ar a 
ay
#$$  m r  m &ara r ( 

ar a 
ay
u am 5 m
<HTML>
<HEAD><TITLE>DOEACC CENTRE - Example 16</TITLE></HEAD>
<BODY>
<B><DIV ALIGN="CENTER"> Employment Exchange</DIV></B>
<PRE>
<FORM METHOD="POST"
ACTION="mailto:employmentexchaNge@Chandigarh.com">
First Name : <INPUT NAME="NAM1" TYPE="TEXT" SIZE="25">
Second Name : <INPUT NAME="NAM2" TYPE="TEXT" SIZE="25">
Father's Name : <INPUT NAME="FNAM" TYPE="TEXT" SIZE="50">
Date of Birth : <INPUT NAME="DOB" TYPE="TEXT" SIZE="10">
Sex Code : <INPUT NAME="SC1" TYPE="CHECKBOX"> M <INPUT
NAME="SC2" TYPE="CHECKBOX"> F
Qualification : <SELECT NAME="QUALI">
<OPTION> High School
<OPTION> Intermediate
<OPTION> Graduate
<OPTION> Post Graduate
<OPTION> Engineer
<OPTION> PhD
</SELECT>
u am 5 mm 
Stream <SELECT NAME="STR">
<OPTION> Science
<OPTION> Arts
<OPTION> Commerce
<OPTION> Computers
</SELECT>
Percentage Marks : <INPUT NAME="PM" TYPE="TEXT" SIZE="5">
Nationality : <INPUT NAME="NAT" TYPE="TEXT" SIZE="15">
Religion : <INPUT NAME="REG" TYPE="TEXT" SIZE="15">
Category : <SELECT NAME="CAT">
<OPTION> SC
<OPTION> ST
<OPTION> General
<OPTION> OTHERS
</SELECT>
Mailing Address : <INPUT NAME="ADR1.1" TYPE="TEXT" SIZE="50">
<INPUT NAME="ADR1.2" TYPE="TEXT" SIZE="50">
Permanent Address : <INPUT NAME="ADR2.1" TYPE="TEXT" SIZE="50">
<INPUT NAME="ADR2.2" TYPE="TEXT" SIZE="50">
<INPUT TYPE="SUBMIT" VALUE="OK"> <INPUT TYPE="RESET" VALUE="CLEAR">
</PRE>
</FORM> </BODY> </HTML>
  u am 5 m
ra
 Œ
1
)r a arm a   r
a a r
)r a a 
 - a-rm- aa r a
rma

-
 
rmar 
2 ,am &  (
2 r & r a(
2 Π&*a
  (
2 )r )  y
 &
  
 (
2 ]ra r r &Dr
" Va u     r(
2 ] r r&*a
 !Va u     r(
2 * mar .)mm  & r a(
2 Œm
& (
)r a a  ry-rma   a a
 
rm
auma

ŒmmaryDay!4
2 -rm 
2 - *.- *
2 ], .], 
2 Œuu).Œuu)
2  ] ,
2 u*u.u*u

2 u am D
 r  

2 ra
 Œ
1
Day5
 
-ram  rm 

m
a
 y 


  r r


  m
  m  
-ram ar 
 a
 a  y a y  a
a ra

  r a m   
 a a
  ay ram a  a
 
 a a   
   r ram &r
(
-r am  ram  
ay a a


a 
   r ram  a a   
 

 r a r 
 
-ram ar a
ay a ay  arra
 a r 

 ra   a a  
)r a
 a-ram m  
ram m  
aa  a 
 r   
 r r  



 m
 ram a
 


 a   
ay 
 a
ram 
     

   ma



 a ram  a a a
aya
ara m  
a r
 ar 
    
%#$$ 
 
 r ram  r
ay
 
m r  r  

 y a m r &  a '( a
 r  a    a 
 
  &  a +4>( r
a a r
 &?(

a
 a a ram  a  a
 r ma

 a 
#$$ r
m
ar  r    a 

 r ram

r
% ay
  m
  #$$ a    ram



 Ä  #$$  

  r  
ay 
r r r  ram  
 ar y r 
Ä  #$$
%   ram r r
 

  
|

      
a  y  a a   a

a


  m   
ay
 a ram 
Y '     
y   a 
   
 a
  ram 

a
  
a r
 ar 
 #$$  *   m   

ay 
 
ram
#$$ a am     r ar
 

ram 
  ar a r

  á  

  &„
<HTML>
<HEAD><TITLE>DOEACC CENTRE ±
Example 17</TITLE></HEAD>
<FRAMESET COLS="20%,75%">
<FRAME SRC="INDEX.HTM">
<FRAME SRC="BLANK.HTM"
NAME="MAIN">
</FRAMESET>
</HTML>
    &„
   

y 
  ram 

 a  r y a
r a ra  r m ram ay  , u am
7  y    ram 
u am 7 m
<HTML>
<HEAD><TITLE>DOEACC CENTRE ± Example
18</TITLE></HEAD>
<FRAMESET COLS="20%,80%">
<FRAME SRC="INDEX.HTM">
<FRAMESET ROWS="30%,70%">
<FRAME SRC="LOGO.HTM" NAME="LOGO">
<FRAME SRC="BLANK.HTM" NAME="MAIN">
</FRAMESET>
</FRAMESET>
</HTML>
     am 7 m

m 
am 
a
 a

m 
a
ar %%r r  
 
a
 ra
 a
ma
 ] 
a r  

 ar  
  a 
 
 a  
a 
Y a
  a 
 
 a   a

     Ä Ä  a
Ä 
Ä  m  a 
   r a r 
ay  y a r r

a r
 ar 

 #$$ *   
  m 
% á#$$  
    m   - 
 

á á #$$  
   m   - 
 

 #$$  rm
  a
m    m 
a 

 #$$  a     m 
a a  a r
 

á #$$  a     m 
a a  
  r
r

Ä  #$$ ra a r r    


%
 
 ar
 m 
a
  '„
<HTML>
<HEAD><TITLE>DOEACC CENTRE - Example
19</TITLE></HEAD>
<BODY>
<EMBED SRC="FIRST.AVI" AUTOSTART="TRUE"
LOOP="TRUE" WIDTH =160 HEIGHT=120
VSPACE =10 HSPACE=20 ALIGN="LEFT">
You are listening the First Music file.
</BODY>
</HTML>
     am 9 m
ra
 Œ
1
2 )r a a V r
a ram 
 / 
 r  m 
2 )r a a ram 
 + r a
   r +
m 
2 )r a a ,a
a
 -ram    ram 
 
 

 r   
  
 ar * 
  

 r
 ram 
2 )r a a ram 

  3m  a  



 
 ram a
a

2 )r a a | a 

 a  
 
ŒmmaryDay!5
2 -ram
2 )r a
 a-ram m  
2 -*uŒu.-*uŒu
2 -*u.-*u
2 , -ram
2 
m 
am 
a
 a 
2 uuD
2 u am D
 r  
 
2 ra
 Œ
1
Day'
DYNA 

Dyam
&D( r aay r
  a 


a

)m

 
)a a
 Πy Πa
r

 a a D
ar
  rr a
 
y !a 
    a 
m 
 

a
y

 „ 
" Πy 
a
  a  rm

 r
 a a
 r  a ara  may  a a  
  
Πy a
m  r ar 
 a   a a
 
 a   a 
 y a r ma
  a
m 

m 
     a   y 
 
a  
 y a  a
 y a y  a
a 
 a a
r  ry ra 
]
  ra  y ma  a
m  r  


y a r
 

!5#0  < =

3  =
 G   
÷H   
÷IJ
!5#0


  ·

] Πy rm
 y
" a
a   r a  ry 


  ry ra

a  ara

"   r  ara
 a
r
a  a r 
"  y  
 a  
   a a
   r! ara
 r  a 
   a 
 r ' a am  a   r! ara
 r 
" @rr
m  =  !am
ya  
 r }

r   

 a ay a
 
a r
m 
a 
 !raa  
 ra 
 !a 


  ·

] ' 
 r a   r  
 mr a  a 
" a  a + @a r
 a }
] 
a   r a
  a r
 !a    a  -r
am   r
" u @rr
m }

 r
m  a  r  a   a
 a a u
& ma
% (  m   ] y  m
 a a y '

 mma yr r r


 rr  r
 a 
r y

 r  ay  r
" u @r r
m }

 r
m  a  r  u  m    y  a
a ar
   a
   y    r
 
r
a  a
 a   r
   
 
Œm a r
  ar
ary  !r  a    a a
 
a y a r r
 y ara r

  Y '
a  

y a a a r
 !a a
r
 a
m
! 
 a  
 ] a y a r a  m
 a
mr a ra ay

-r am   r


)a a  a ar a
"  @  +4  a  
 r}
  „
<HTML>
<HEAD>
<STYLE TYPE="text/css">
H1 {font:25 pt; font-family:fantasy; font-style:oblique; color:blue}
body {fony:10 pt; font-family:monospace; font-style:normal; color:green}
HR {height:10; color:blue}
LI {font:15 pt; color:orange}
</STYLE>
<TITLE> CSS </TITLE>
</HEAD>
<BODY>
<H1>COMPUTERS</H1>
<HR>
Computer is an electronic device. It works on stored program concept<BR>
Computer can take logical decision. <BR>
<H1> I/O devices</H1>
<OL>
<LI> Mouse
<LI>Keyboard
<LI>Printer
</OL>
</BODY>
</HTML>
    „
„
)a
a    a r 
] a y   
y  am y r a ar
ar  m  a

m a ar 
] y ma a  m  a m m r  a a y
 r
 Ñ  
Ñ  
 
 
 a 
rm  a a '
 

a
 
 '  a  
 a r a a
 y a r
  
a ara    
] yr m   a rr       
  a .  a  
  r a  r 
"
 @  4 = rDarra }

   a a r   a  
m a
)a # $
 $
)a  1
y a am r

  
 a 
,    a  r a

y  )a  r 
 m      a    m  &)y
a 
 ( a   a &
 (
  
 r 
 m  & a (

|
  'r a
  ' a a r a a a   ua

a ]  m   m a a 
r  a
a  r a
  a


"] @  4  rma  a= !


   4
}
  „
<HTML>
<HEAD>
<STYLE TYPE="text/css">
H1 {font:25 pt ; font-family:fantasy ; font-style:oblique ; color:blue}
.bdy {font:10 pt ; font-family:monospace ; font-style;normal ;
color:green}
HR {height:10; color;blue}
.LSTITM {font:15 pt ; color:orange}
</STYLE>
<TITLE>CLASS</TITLE>
</HEAD>
<BODY CLASS="BDY">
<H1 ALIGN=CENTRE>COMPUTERS</H1>
<HR>
Computer is an electronic device. It works on stored program concept<BR>
Computer can take logical decision. <BR>
<H1> I/O devices</HI>
<OL>
<LI CLASS="LSTITM">Mouse
<LI CLASS="BDY">Keyboard
<LI CLASS="LSTITM´>Printer
</OL>
</BODY>
</HTML>
    „

 ]D 
  y a a a ]D  a )ŒŒ r A
Y r  

 6


r    r &  ra  ar (
   $]D$
] y   a
    r a  a   ]D
a r

 ay  m    a  y ay  y


  r '  ara


 &  ra  ar (
 ' a a ]D  r ŒYu  m  
2Πy a  ma a   
m a  y r

 m a a ma
  m :> ar r a    r  
m 
 
r 
"6]D ] @ !
%  :> = r = a ry }
",  a
 ]D ] a  ]D r     
m  )a
" )ŒŒ#BŒC ]D#$]D ]$; yar.
u am / m
<HTML>
<HEAD>
<STYLE TYPE="text/css">
H1 {font:25 pt; font-family:fantasy ; font-style:oblique ; color:blue}
body {font:10 pt ; font-family:monospace ; font-style:normal ;
color:green}
HR {height:10 ; color:blue}
.LST {font:10 pt ; color:green}
#IDTOLI {font-size:110%;color:blue ; background:yellow}
</STYLE>
<TITLE>Adding ID in Style Sheet</TITLE>
</HEAD>
<BODY>
<H1>COMPUTERS</H1>
<HR>
Computer is an electronic device. It works on stored program concept<BR>
Computer can take logical decision. <BR>
<H1> I/O devices</H1>
<OL>
<LI><A CLASS="LST">Mouse</A>
<LI><A CLASS="LST´ ID=´IDTOLI">keyboard</A>
<LI><A CLASS="LST">Printer</A>
</OL>
</BODY>
</HTML>
  u am / m


a   m  a ay a rm
  r

y  
] a r y 

    r a y   ay
  r  a  ]  y   m   y 
 a    ar
  r '
y
  

a
 
Y a  
 -
 
 a a &a

a r ay   r   m  (

"Π, ra @ ! ra rm ra }


"Π, r @ ! ra rm ra }
u am 0 m
<HTML> <HEAD> <STYLE TYPE="text/css">
H1 {font:25 pt ; font-family:fantasy ; font-style:oblique ;
color:blue}
body {font:10 pt ; font-family:monospace ; font-style:normal ;
color:green}
HR {height:10; color:blue}
LI {font:15 pt ; color:orange}
SPAN.uppercase {text-transform:uppercase}
SPAN.lower {text-transform:lowercase}
<STYLE> <TITLE>CSS</TITLE> </HEAD>
<BODY>
<H1>COMPUTERS</H1> <HR>
Computer is an electronic device. It works on stored program
concept <BR>
Computer can take logical decision.<BR>
<H1> I/O devices</H1>
<OL>
<LI><SPAN CLASS="uppercase">Mouse</SPAN>
<LI><SPAN CLASS="lower">KEYBOARD</SPAN>
<LI>Printer
</OL>
</BODY> </HTML>
ra
 Œ
1
2 )r a y  
ay  a

 
 r 
y
2 )r a y r a a  a a 
 r  y
  a a r
  &
/ 15:-]%"#
/  



/ 1 ÷ 

/ -   ÷

/ - ]1

/ !2-:
/ 2 ÷!

 
Day7


 Πy Π

-r y 
rma
   r a a '
a ara
'    ary r a y  
a ar   a 

] a y a   y 
 a ara
m   a a 
  a m  

Y a   r   y  '


rma
 y



   r m  a  


 Πy Π 1
 r ' a 
  
   
 

ŒYuY u#$ . C

@ +4 = !am


ya a y= ! y 
D =r }

D+@ 4 = !am


ya a y= ! y 
D =r r }

DY@ : = !am


ym a = ! y rma=
r r }

*@
 4=r }

Œ]@ 4 =rra }

.ŒYu


 Πy Π 1
,  a  
 r |   Πa

 a  
y  m  
] yr Πy
%  |   Πa  m m   r a a   
 -  r 
.á  a 
&Πy
rma
    r 
 
m  (  
  
  y

  # Πy   #B . C
á  # $-]Vu! m$  #$Œ y $

Œa  m  a    Œ y


%  |   Π m m 
 ]u ]

  
 
r 4        a ar
 m  
  !„
<HTML> <HEAD>
<LINK HREF="FIVE-1.HTM" REL=stylesheet TYPE="text/css">
<TITLE>Linking Style Sheet</TITLE> </HEAD>
<BODY CLASS="BDY">
<H1 ALIGN=CENTER>Languages</H1> <HR>
Classification of computer languages
<H2 CLASS="HD2">
<OL>
<L1CLASS="LSTITM">Low level languages
<UL>
<LI STYLE="COLOR:blue ; FONT:10 pt">Machine language
<LI STYLE="COLOR:blue ; FONT:10 pt">Assembly language
</UL>
<LI CLASS="LSTITM">High level language
<UL>
<LI STYLE="COLOR:blue ; FONT:10 pt">BASIC
<LI STYLE="COLOR:blue;FONT:10pt">C
<LI STYLE="COLOR:blue ; FONT:10pt">C++
</UL> </OL>
</H2> </BODY> </HTML>
    !„
„   

u a y a y a r
 ar aa
a  yA  r  m
mr  y Y' r  
% m   m a y' ar ay
r  
 D
 

 a ry  
ara r

   
 - !am
y

- - !am


y

- ! y - !


- !
%
„    
  r  

  raa r
 m 
)r a r
a r!r a r!
ma
a r!r  a a r!a am 
a r!



 
r  

 r r


 a  m  

r! a
  r! a

! ra
  r
a!a

! ra rm !a

!
  
 !a

„    

Œ
 a  r  a 
  ara r

  
& m
m


 ($ $ a
ar
 ar
!  ar
!r

ar
! m ar
!  a

a
 !  a
 !r
 a
 ! m
a
 !  r r!
  r r! !
 
r r!r
 !
  r r! m!
  r r!  !
 

r r!r r r! y r r! 


r r!r
 r r! m r r! 
r r |
  

-a
 
 
 r

 
Œ
 ma
% a
mr a  
y  !
  ara r

   

] y   
 
 ar $ Πy Πr
Yr r r$ y' a rama
 am  
(

  a r
 ar  !am
y  ! y   !
 
 !
%  a & rr

 y(  

a a 
a r a r r r
  ra
 ara r

 a  am
m 
 
  1
a     
 a     r  a r
 

  
 

- !am
y  mma! 
m
 D    am
y
am &  
 r  
a( a.r 

 & r
 a ! r
 r
  a a y r
m a (
- ! y ,rma
a
 r 
D

- !
 ,rma   r 
 r r   

m r
a a
&:: +:: /:: 0:: 4:: 5:: ':: 7:: r
9::(
- !
%  rm a   a 
% & ! ma !
ma ma m 
m ar  !ar  !ar (
r a

% &ar  ma r( a m r & 
 (
r a  r  a   ar   m  '
% (
 Ä  
 
 r

 
a ry  
y  a ara  a  m  '
r r a a r

m  r a
ma 
 a r a r


   a r a r
  ra
a r a r
 a a   a    m  
  r 


  %„    
  

)r Π' a  m  '  ! r!am &a 



r&a a    a (rar
$r rr$( 
a r! Π

  r
a r!am ar!
r  m  a r  r ra ar 
a r! Π a r
ma  * r 

ma

 
 a r
 r
  a ara  a a '   y r y ra
 !rar a
a  

a 

  %„    
  

|r! a
 ]r a    a 
a    ,rmara  
 
 r
 r! a
 ]r a    a 
a    ,rmara  
 
  r
 ! ra
 '  ra
 a  m   , r rmr   
rm  r
  r
 
 r 


V r
a!a
 D rm
 a  m  '  r
a


 a 
    r  ! m
 
 mr  m=aa  a
 r  a     m   


 ! ra rma
 
a  ra rma
    )a
a
% &    
 


aa (
 ra  ra r

 !a
 
  

    m    r
   rr-
y

 !
  ]    
r 
     r  a     m  
 ra
  

 !
 D rm
   
a      ,rmaram r  r r  a 
a 
  
 
      m  '  
% 



  
, u am   
  
  a
  

  r 
 !r a rm   
  
 a 
 +' 

 a   
a
a  


 4: 
 rm    
 
 a +: 
 rm    
y 

  a   
 a 
u am 5 m a y'  
ay 

u am 5
  „
<HTML>
<HEAD>
<TITLE>Positions</TITLE>
</HEAD>
<BODY>
<BR><BR><BR>
This is line 1
<SPAN Style =
"position:absolute;top:50;left:20">
This is line2 with absolute positioning.
</SPAN>
</BODY>
</HTML>
    „
)a   u am 5 m
,  ' a  


  
 + rm a   r a
 





r a
 

   m  


 r a
      m   a 
r   

  m   
 +
 4:
 
rm
 a+:
    r
    
 
ra
 Œ
1
2 )r a y
 a 
 a 
  m
 a  r
 m 

2 )r a y r  a m r
  (
/ #  ! ÷!

/ 0÷ !5#0
/ * -   

/ %÷ .   -   

/  -   

/ 2
  
/ 2 ÷!


Day9
] r


M  @   ! |"


M   !|
   ! 
        #
M      
  #
| M  $

MavaScript was designed to add interactivity to HTML


pages
MavaScript is a scripting language (a scripting language is
a lightweight programming language)
A MavaScript consists of lines of executable computer code
A MavaScript is usually embedded directly into HTML pages
MavaScript is an interpreted language (means that scripts
execute without preliminary compilation)
Everyone can use MavaScript without purchasing a license
u  |   $

With traditional programming languages,


like C++ and Mava, each code statement
has to end with a semicolon.
Many programmers continue this habit
when writing MavaScript, but in general,
semicolons are ! However,
semicolons are required if you want to
put more than one statement on a single
line.
% &  

Browsers that do not support MavaScript will display


the script as page content. To prevent them from
doing this, we may use the HTML comment tag:
ð   
   
ð     
ð 
The two forward slashes at the end of comment line
(//) are a MavaScript comment symbol. This prevents
the MavaScript compiler from compiling the line.
|  ' M  

MavaScripts in a page will be executed immediately while the page loads


into the browser. This is not always what we want. Sometimes we want to
execute a script when a page loads, other times when a user triggers an
event.

      ( Scripts to be executed when they are


called, or when an event is triggered, go in the head section. When you
place a script in the head section, you will ensure that the script is loaded
before anyone uses it.
ð
ð 
ð   
   

ð 
ð  
  (

Scripts to be executed when the page loads go in the


body section. When you place a script in the body
section it generates the content of the page.
ð
ð 
ð  
ð 
ð  
   

ð 
ð 
    

Y   ! 
     
   #
  
 
 )*+, *
####
+ 
+ 

 )*+, *
####
+ 
+
+  
ºu M  

Sometimes you might want to run the same MavaScript on


several pages, without having to write the same script on
every page.
To simplify this, you can write a MavaScript in an external
file. Save the external MavaScript file with a .js file
extension.
To use the external script, point to the .js file in the "src"
attribute of the <script> tag:
ð
ð 
ð  

 
ð 
ð  
ð 
ð 
ð 
è 

A variable is a "container" for information you


want to store. A variable's value can change
during the script. You can refer to a variable
by name to see its value or to change its
value.
Rules for variable names:
Variable names are case sensitive
They must begin with a letter or the
underscore character
D è 

You can create a variable with the var


statement:
   Ô 
You can also create a variable without
the var statement:
 Ô 
Aèè 

You can assign a value to a variable like this:

     ! Or like this:


   !"

The variable name is on the left side of the


expression and the value you want to assign
to the variable is on the right. Now the
variable "strname" has the value "Hege".

! !è 

When you declare a variable within a function, the


variable can only be accessed within that function.
When you exit the function, the variable is destroyed.
These variables are called local variables. You can
have local variables with the same name in different
functions, because each is recognized only by the
function in which it is declared.
If you declare a variable outside a function, all the
functions on your page can access it. The lifetime of
these variables starts when they are declared, and
ends when the page is closed.
ra
 Œ
1
2 |r
a r
 a 
ay m   m r + a
/0
2 |r
a r
 a 
ay  a ra  4 m r 
  !D-
2] r

2|a 
3aaŒr
 A
2u
 Πa m  |
aΠm
A
2 a   rr r
2| r      3aaŒr

2Œr
 
  y 

2Œr
 
   ya   a 

2
 au ra3aaŒr

2Var
a
2D ar aVar
a
2
aVa  aVar
a
2

m Var
a
2 ra
aŒ

Day:
  
Very often when you write code, you want to perform
different actions for different decisions. You can use
conditional statements in your code to do this.
In MavaScript we have the following conditional
statements:
!  - use this statement if you want to execute
some code only if a specified condition is true
!###  - use this statement if you want to
execute some code if the condition is true and another
code if the condition is false
!###!####  - use this statement if you
want to select one of many blocks of code to be executed
   - use this statement if you want to
select one of many blocks of code to be executed
!  

You should use the if statement if you want


to execute some code only if a specified
condition is true.

#m 


$
m    m  
m 


Ô 
%
Note that if is written in lowercase letters.
Using uppercase letters (IF) will generate a
MavaScript error!
u .

ð  
   
  &! !!#
   '(
 ) 
 ! 
#ð'(
$
 ð &!ð  
%
ð 
u /

ð  
   
 * # ''
 ) 
 ! 
#''
$ ð *ð  
%
ð 
!###  

If you want to execute some code if a condition


is true and another code if the condition is not
true, use the if....else statement.

#m 


$
m    m  
m 


Ô 
%
 
$
m    m  
m 


Ô  
%
u 
ð  
   
+#   '(,
!  &! !!
- !  &  !!
 ) 
 ! 
#ð'($
 &! 
%
 $
 &  
%
ð 
!###!###  

You should use the if....else if...else statement if you want


to select one of many sets of lines to execute.

#m 


$
m    m  
m 


Ô 
%
 #m 


$
m    m  
m 


Ô 
%
 
$
m    m  
m 

 m 

  
%
u 

ð  
   
 ) 
 ! 
#ð'($
 ð &!ð  
%
 #'(..ð'/$
 ð & ð  %
 $
 ð ð  
%
ð 
 M      

You should use the switch statement if you want to select


one of many blocks of code to be executed.


$
 '0 m m   m 
 1
 20 m m   m 
 1

# 0m    m  



Ô
  mÔ 
%
u 
ð  
   
3 ##!! 
   4 5 (,
6 ',7  2,
 ) 
) !) 
) 
$
 80 9 9  
 1
 /0 55   
 1
 (0 55  
 1
# 0 +:1!#  
1 
%
ð 
M  %  
A  %  
%  D  u  0

+ Addition x=2 4
y=2
x+y
- Subtraction x=5 3
y=2
x-y
* Multiplication x=5 20
y=4
x*y
/ Division 15/5 3
5/2 2.5

% Modulus (division remainder) 5%2 1


10%8 2
10%2 0
++ Increment x=5 x=6
x++

-- Decrement x=5 x=4


x--
A %  

%  u     A

= x=y x=y

+= x+=y x=x+y

-= x-=y x=x-y

*= x*=y x=x*y

/= x/=y x=x/y

%= x%=y x=x%y
  %  
%  D  u 

== is equal to 5==8 returns false

=== is equal to (checks for both x=5


value and type) y="5"
x==y returns true
x===y returns false
!= is not equal 5!=8 returns true

> is greater than 5>8 returns false

< is less than 5<8 returns true

>= is greater than or equal to 5>=8 returns false

<= is less than or equal to 5<=8 returns true



%  

%  D  u 

UU and x=6
y=3
(x < 10 UU y > 1) returns
true

|| or x=6
y=3
(x==5 || y==5) returns
false

! not x=6
y=3
!(x==y) returns true
 % 

A string is most often text, for example


"Hello World!". To stick two or more
string variables together, use the +
operator.
txt1="What a very"
txt2="nice day!"
txt3=txt1+txt2
The variable txt3 now contains "What a
verynice day!".
 %  1

To add a space between two string variables,


insert a space into the expression, OR in one
of the strings.
txt1="What a very"
txt2="nice day!"
txt3=txt1+" "+txt2
Or
txt1="What a very "
txt2="nice day!³
txt3=txt1+txt2

The variable txt3 now contains "What a very


nice day!".
% 
MavaScript also contains a conditional operator that
assigns a value to a variable based on some condition.

   ; '0 2
u 

!!  <=>5 ; ) <  0 ) "

If the variable visitor is equal to PRES, then put the


string "Dear President " in the variable named
greeting. If the variable visitor is not equal to PRES,
then put the string "Dear " into the variable named
greeting.
ra
 Œ
1
2 |r
a r
 a 
ay  ma
m  r
m r
2 |r
a r
 a aa 
m
 r  a
am 
2 |r
a r
 a  r a ) 
ra  m ra r
 -ar 
 m ra r 
  !D.2
‡  
‡!  
‡u .
‡u /
‡!###  
‡u 
‡!###!###  
‡u 
‡ M      
‡u 
‡M  %  
‡A %  
‡  %  
‡
%  
‡  % 
‡  %  1
‡% 
‡ '  
Day
M  '&

‡Alert box
‡Alert box with line breaks
‡Confirm box
‡Prompt box
A &

An alert box is often used if you want to make sure


information comes through to the user. When an alert
box pops up, the user will have to click "OK" to
proceed.

(

 
 
! &

A confirm box is often used if you want the


user to verify or accept something.
When a confirm box pops up, the user will
have to click either "OK" or "Cancel" to
proceed.
If the user clicks "OK", the box returns true. If
the user clicks "Cancel", the box returns false.

(

confirm("sometext")
'  &
A prompt box is often used if you want the
user to input a value before entering a
page.
When a prompt box pops up, the user will
have to click either "OK" or "Cancel" to
proceed after entering an input value.
If the user clicks "OK" the box returns the
input value. If the user clicks "Cancel" the
box returns null.

(

prompt("sometext","defaultvalue")
M  3

A function is a reusable code-block that will be


executed by an event, or when the function is called#
To keep the browser from executing a script as soon
as the page is loaded, you can write your script as a
function.
A function contains some code that will be executed
only by an event or by a call to that function.
You may call a function from anywhere within the
page (or even from other pages if the function is
embedded in an external .js file).
Functions are defined at the beginning of a page, in
the <head> section.
u 4 3
<html>
<head>
<script type="text/javascript">
function displaymessage()
{
alert("Hello World!")
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!"
onclick="displaymessage()" >
</form>
</body>
</html>
D!3

The syntax for creating a function is:


function O ( 

 
)
{

}
var1, var2, etc are variables or values passed into the
function. The { and the } defines the start and end of the
function.

A function with no parameters must include the parentheses


() after the function name:
function O ()
{

}
     

The return statement is used to specify the value that is


returned from the function.
u 
The function below should return the product of two
numbers (a and b):
function prod(a,b)
{
x=a*b
return x
}
When you call the function above, you must pass along
two parameters:
2,?

The returned value from the prod() function is 6, and it


will be stored in the variable called product.
M  


Very often when you write code, you want the


same block of code to run over and over again
in a row. Instead of adding several almost
equal lines in a script we can use loops to
perform a task like this.
In MavaScript there are two different kind of
loops:
! - loops through a block of code a specified
number of times
 - loops through a block of code while a
specified condition is true
 ! 


The for loop is used when you know in


advance how many times the script
should run.

for
(var=startvalue;var<=endvalue;var=
var+increment)
{
 
}
u 
<html>
<body>
<script type="text/javascript">
var i=0
for (i=0;i<=10;i++)
{
document.write("The number is " + i)
document.write("<br />")
}
</script>
</body>
</html>
  

The while loop is used when you want


the loop to execute and continue
executing while the specified condition is
true.
while (var<=endvalue)
{
 
}
u 
<html>
<body>
<script type="text/javascript">
var i=0
while (i<=10)
{
document.write("The number is " + i)
document.write("<br />")
i=i+1
}
</script>
</body>
</html>
 ### 


The do...while loop is a variant of the while loop. This


loop will always execute a block of code ONCE, and
then it will repeat the loop as long as the specified
condition is true. This loop will always be executed
once, even if the condition is false, because the code
is executed before the condition is tested.
do
{
 
}
while (var<=endvalue)
u 
<html>
<body>
<script type="text/javascript">
var i=0
do
{
document.write("The number is " + i)
document.write("<br />")
i=i+1
}
while (i<0)
</script>
</body>
</html>
  
The break command will break the loop and continue executing the code
that follows after the loop (if any).
u 
<html>
<body>
<script type="text/javascript">
var i=0
for (i=0;i<=10;i++)
{
if (i==3){break}
document.write("The number is " + i)
document.write("<br />")
}
</script>
</body>
</html>

The continue command will break the current loop and continue
with the next value.
u 

<html>
<body>
<script type="text/javascript">
var i=0
for (i=0;i<=10;i++)
{
if (i==3){continue}
document.write("The number is " + i)
document.write("<br />")
}
</script>
</body>
</html>
3 ###  
The for...in statement is used to loop (iterate) through
the elements of an array or through the properties of
an object.
The code in the body of the for ... in loop is executed
once for each element/property.

for (variable in object)
{
 
}

The variable argument can be a named variable, an


array element, or a property of an object.
u 
<html>
<body>
<script type="text/javascript">
var x
var mycars = new Array()
mycars[0] = "Saab"
mycars[1] = "Volvo"
mycars[2] = "BMW"

for (x in mycars)
{
document.write(mycars[x] + "<br />")
}
</script>
</body>
</html>
ra
 Œ
1
2 |r
a r
 a a  yr am
 a
 
a 
ay a am
 a  a  
2 |r
a r
 a 
ay  a r
a  a m r
2 |r
a r
 a 
ay  r
m m r rm  
::
  !D..
2M
Ä 
2 Ä
2  
 Ä
2 Ä
2M
 
 
2á 
 

2 „    
2M

2 „ 
2 „ „
 
2 „ „
 
2 
2  

2  
2
  

Day+
u

Every element on a web page has certain events


which can trigger MavaScript functions. For example,
we can use the onClick event of a button element to
indicate that a function will run when a user clicks on
the button. We define the events in the HTML tags.
Examples of events:
A mouse click
A web page or an image loading
Mousing over a hot spot on the web page
Selecting an input box in an HTML form
Submitting an HTML form
A keystroke
º

The onload and onUnload events are triggered


when the user enters or leaves the page.
The onload event is often used to check the
visitor's browser type and browser version,
and load the proper version of the web page
based on the information.
Both the onload and onUnload events are also
often used to deal with cookies that should be
set when a user enters or leaves a page.
3&  

The onFocus, onBlur and onChange events are


often used in combination with validation of
form fields.
Below is an example of how to use the
onChange event. The checkEmail() function
will be called whenever the user changes the
content of the field:
ð 
  @ ?(    
 ! 1>  A
  

The onSubmit event is used to validate ALL


form fields before submitting it.
Below is an example of how to use the
onSubmit event. The checkForm() function will
be called when the user clicks the submit
button in the form. If the field values are not
accepted, the submit should be cancelled. The
function checkForm() returns either true or
false. If it returns true the form will be
submitted, otherwise the submit will be
cancelled:
ð#    

 
   19 
 %  %

onMouseOver and onMouseOut are often


used to create "animated" buttons.
Below is an example of an onMouseOver
event. An alert box appears when an
onMouseOver event is detected:
ð # 0   
  :B6 -:A
#   
ð! "!#  '(( ! ?( ð 
M  %, 

MavaScript is an Object Oriented Programming (OOP)


language. An OOP language allows you to define your own
objects and make your own variable types.
an object is just a special kind of data. An object has
properties and methods.

'  


Properties are the values associated with an object.

 
Methods are the actions that can be performed on objects
 %,

The String object is used to manipulate a stored piece of


text

The following example uses the length property of the


String object to find the length of a string:
 
  

!

 
  am      r)a &(m   Πr
 -  
 r a r
   ra  r 
var txt="Hello world!"
document.write(txt.toUpperCase())
D%,
The Date object is used to work with dates and times.
We define a Date object with the new keyword. The following
code line defines a Date object called myDate:
 ) ) 

We can easily manipulate the date by using the methods


available for the Date object.
In the example we set a Date object to a specific date (14th
Manuary 2010):
 ) ) 
)  93 2('(,(,'C

we set a Date object to be 5 days into the future:


 ) ) 
)  ) ) !) D8
  D

The Date object is also used to compare two dates.


The following example compares today's date with the
14th Manuary 2010:

var myDate=new Date()


myDate.setFullYear(2010,0,14)
var today = new Date()
if (myDate>today)
alert("Today is before 14th January 2010")
else
alert("Today is after 14th January 2010")
A %,
The Array object is used to store a set of values in a single
variable name.
We define an Array object with the new keyword. The
following code line defines an Array object called myArray:
 B B 
There are two ways of adding values to an array (you can add
as many values as you need to define as many variables you
require).

   B     


B ?
  E(F 5    E(F 5 
  E'F G"   E'F G 
  E2F H6"   E2F H6"

   B  5 , G , H6 


A5 !A 
You can refer to a particular element in an array by referring to
the name of the array and the index number. The index number
starts at 0.
The following code line:
  E(Fwill result in the

following output:
5

To modify a value in an existing array, just add a new value to


the array with a specified index number:
  E(F -"

Now, the following code line:


  E(F

will result in the following output:


-
ra
 Œ
1
2 |r
a r
 a a  4 am  r  m
 a
array a 
ay  m
 r r
2 |r
a r
 a 
ay  ay a
 r r
2 |r
a r
 a a  a r
 a 
ay 
    a r
 
  !D./
‡u
‡º
‡3&  
‡  
‡ %  %
‡M  %, 
‡  %,
‡D%,
‡  D
‡A %,
‡A5 !A 
‡'  
Day/
M   

A cookie is a variable that is stored on the visitor's computer.


Each time the same computer requests a page with a browser,
it will send the cookie too. Examples of cookies:
Name cookie - The first time a visitor arrives to your web page,
he or she must fill in her/his name. The name is then stored in a
cookie. Next time the visitor arrives at your page, he or she
could get a welcome message like "Welcome Mohn Doe!" The
name is retrieved from the stored cookie
Password cookie - The first time a visitor arrives to your web
page, he or she must fill in a password. The password is then
stored in a cookie. Next time the visitor arrives at your page,
the password is retrieved from the cookie
Date cookie - The first time a visitor arrives to your web page,
the current date is stored in a cookie. Next time the visitor
arrives at your page, he or she could get a message like "Your
last visit was on Tuesday August 11, 2005!" The date is
retrieved from the stored cookie
    

we create a function that stores the name of the


visitor in a cookie variable
function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate)
}
u 
Another function that checks if the cookie has been set:

function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=")
if (c_start!=-1)
{
c_start=c_start + c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return
unescape(document.cookie.substring(c_start,c_end))
}
}
return null
}
u 
the function that displays a welcome message if the cookie is set, and if
the cookie is not set it will display a prompt box, asking for the name of
the user

function checkCookie()
{
username=getCookie('username')
if (username!=null)
{alert('Welcome again '+username+'!')}
else
{
username=prompt('Please enter your name:',"")
if (username!=null||username!="")
{
setCookie('username',username,365)
}
}
}
3 è

M  3 è


MavaScript can be used to validate input data
in HTML forms before sending off the content
to a server.
Form data that typically are checked by a
MavaScript could be:
has the user left required fields empty?
has the user entered a valid e-mail address?
has the user entered a valid date?
has the user entered text in a numeric field?
06 3
The function below checks if a required field has been left empty.
If the required field is blank, an alert box alerts a message and
the function returns false. If a value is entered, the function
returns true (means that data is OK):

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}
}
}
u 

u4 è
The function below checks if the content has the general
syntax of an email

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false}
else {return true}
}
}
ra
 Œ
1
2 )r a a rm a 
ay a rrr m a   m

 ar m y
2 )r a a 
a r   r am a ar
2 |r
a r
  r r
 
rma
  

  !D.7
‡ M   
‡     
‡ 3 è
‡ 06 3
‡ '  
Day0
| A '$

‡ASP stands for Active erver 'ages


‡ASP is a program that runs inside 
‡IIS stands for nternet nformation ervices
‡IIS comes as a free component with |
/222
‡IIS is also a part of the |N8#2%
'
‡The Option Pack can be  from
Microsoft
‡'| is a smaller - but fully functional - version of
IIS
‡PWS can be found on your |-9+-:D
| A '3$
‡An ASP file is just the same as an HTML
file
‡An ASP file can contain text, HTML,
XML, and scripts
‡Scripts in an ASP file are executed on
the server
‡An ASP file has the file extension ".asp"
DA 'D!! !  

$
‡When a browser requests an HTML file,
the server returns the file
‡When a browser requests an ASP file,
IIS passes the request to the ASP
engine. The ASP engine reads the ASP
file, line by line, and executes the scripts
in the file. Finally, the ASP file is
returned to the browser as plain HTML
| A '! $
‡Dynamically edit, change or add any content of a Web
page
‡Respond to user queries or data submitted from HTML
forms
‡Access any data or databases and return the results to a
browser
‡Customize a Web page to make it more useful for
individual users
‡The advantages of using ASP instead of CGI and Perl, are
those of simplicity and speed
‡Provides security since your ASP code can not be viewed
from the browser
‡Since ASP files are returned as plain HTML, they can be
viewed in any browser
‡Clever ASP programming can minimize the network traffic
'|  A '
|-:
1. Open the A4 folder on your Windows98 CD,
find the '| folder and run the # file.
2. An ! will be created on your
harddrive. Open it and find the   folder.
7#  ! , like "MyWeb", under
wwwroot.
8# º to write some ASP code, save
the file as "test1.asp" in the "MyWeb" folder.
5. Make sure your Web server is running - The
installation program has added a new icon on your
task bar (this is the PWS symbol). Click on the
icon and press the Start button in the window that
appears.
;# %   and type in
"http://localhost/MyWeb/test1.asp", to view your
first ASP page.
ra
 Œ
1
2 ] a |Πr r  |
97
2 ] a ]]ΠΠr r  |
+::: Œy m
  !D.8

‡| A '$
‡| A '3$
‡DA 'D!! !  
$
‡| A '! $
‡'|  A '|-:
‡'  
Day4
 & 0
An ASP file normally contains HTML tags,
just like an HTML file. However, an ASP
file can also contain    ,
surrounded by the delimiters < and
<. Server scripts are 
   and can contain any
expressions, statements, procedures, or
operators valid for the scripting
language you prefer to use.
 0%,
The |  method of the ASP
0%, is used to send
content to the browser. For example,
the following statement sends the text
"Hello World" to the browser:
<%
response.write("Hello World!")
%>
è&  
To set MavaScript as the default scripting language for
a particular page you must insert a language
specification at the top of the page:

<%@ language="javascript"%>
<html>
<body>
<%
Response.Write("Hello World!")
%>
</body>
</html>
M  
To set MavaScript as the default scripting language for
a particular page you must insert a language
specification at the top of the page:
<%@ language="javascript"%>
<html>
<body>
<%
Response.Write("Hello World!")
%>
</body>
</html>
A 'è 
A variable is used to store information. If the variable is declared
outside a procedure it can be changed by any script in the ASP
file. If the variable is declared inside a procedure, it is created
and destroyed every time the procedure is executed

! !è 4 A variable declared outside a procedure


can be accessed and changed by any script in the ASP file. A
variable declared inside a procedure is created and destroyed
every time the procedure is executed. No scripts outside the
procedure can access or change the variable.
è 4 Session variables are used to store
information about ONE single user, and are available to all pages
in one application. Typically information stored in session
variables are name, id, and preferences.
Aè 
Application variables are also available to all pages in one
application. Application variables are used to store information
about ALL users in a specific application.
A ''  
The ASP source code can contain procedures Example

<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>
<p>Result: <%call vbproc(3,4)%></p>
</body>
</html>
ra
 Œ
1
2 |r
a r
 a 
ay m   m r + a
/0
2 |r
a r
 a 
ay  a ra  4 m r 
  !D.9

‡ The Basic Syntax Rule


‡ The Response Object
‡ VBScript
‡ MavaScript
‡ ASP Variables
‡ ASP Procedures
‡ Practical Session
Day5
-

The ASP source code can contain functions:

<%@ language="javascript" %>


<html>
<head>
<%
function jsproc(num1,num2)
{
Response.Write(num1*num2)
}
%>
</head>
<body>
<p>Result: <%jsproc(3,4)%></p>
</body>
</html>
º 
The Request object may be used to retrieve user
information from forms.

3  (
<form method="get" action="simpleform.asp">
First Name: <input type="text" name="fname" />
<br />
Last Name: <input type="text" name="lname" />
<br /><br />
<input type="submit" value="Submit" />
</form>
06#=   
 * D   ryΠr
 mma
    a 
arm

m #$ $]rma
  rmarm
  um 


  
 ry &

 
ay 
  r r' ar ar(aa 
m
  
am 
rma
  
]a r y $
$a$a $
  rm am a   *     
r r
  

http://www.mysite.com/simpleform.asp?fname=Bill&lname=Gates
u 
<body>
Welcome
<%
response.write(request.querystring("fname"))
response.write(" " & request.querystring("lname"))
%>
</body>
06#3 
 * D -rmmma
    a 
arm
m #$ $
]rma
  rmarm
   Œm 



    r aa 

m
  am 
rma
  
]a r y $
$a$a $
  rm am a   *     
r r
  

http://www.mysite.com/simpleform.asp
 m  a   Π
 $
m rma $ a
   
  r
 
<body>
Welcome
<%
response.write(request.form("fname"))
response.write(" " & request.form("lname"))
%>
</body>
ra
 Œ
1
‡ Interact with a user in a form that uses the "get"
method
‡ Interact with a user in a form that uses the "post"
method
‡ Interact with a user in a form with radio buttons
  !D.;

‡ Functions
‡ User Input
‡ Request.QueryString
‡ Request.Form
‡ Practical Session
Day'
A ' 
A cookie is often used to identify a user.
A cookie is a small file that the server
embeds on the user's computer. Each
time the same computer requests a
page with a browser, it will send the
cookie too. With ASP, you can both
create and retrieve cookie values.
  

The "Response.Cookies" command is used to create


cookies.
<%
Response.Cookies("firstname")="Alex"
%>
It is also possible to assign properties to a cookie, like
setting a date when the cookie should expire:
<%
Response.Cookies("firstname")="Alex"
Response.Cookies("firstname").Expires=#May
10,2002#
%>
0  è
The "Request.Cookies" command is used to retrieve a cookie
value.
<%
fname=Request.Cookies("firstname")
response.write("Firstname=" & fname)
%>
A  >
If a cookie contains a collection of multiple values, we
say that the cookie has Keys.

<%
Response.Cookies("user")("firstname")="John"
Response.Cookies("user")("lastname")="Smith"
Response.Cookies("user")("country")="Norway"
Response.Cookies("user")("age")="25"
%>
u 
<html>
<body>
<%
dim x,y
for each x in Request.Cookies
response.write("<p>")
if Request.Cookies(x).HasKeys then
for each y in Request.Cookies(x)
response.write(x & ":" & y & "=" &
Request.Cookies(x)(y))
response.write("<br />")
next
else
Response.Write(x & "=" & Request.Cookies(x) & "<br />")
end if
response.write "</p>"
next
%>
</body>
</html>
ra
 Œ
1
2 )r a a rm a 
ay a rrr m a   m

 ar m y
2 )r a a 
a r   r am a ar
2 |r
a r
  r r
 
rma
  

  !D.?

‡ ASP Cookies
‡ How to Create a Cookie
‡ Retrieve a Cookie Value
‡ A Cookie with Keys
‡ Practical Session
Day7
| !&  DN%   $

If your application deals with browsers


that do not support cookies, you will
have to use other methods to pass
information from one page to another in
your application. There are two ways of
doing this:
A   º0

You can add parameters to a URL:


ð #  ;# I. 5 &
< !ð 
And retrieve the values in the "welcome.asp" file like
this:
<%
fname=Request.querystring("fname")
lname=Request.querystring("lname")
response.write("<p>Hello " & fname & " " &
lname & "!</p>")
response.write("<p>Welcome to my Web
site!</p>")
%>
º!
You can use a form. The form passes the user input to "welcome.asp"
when the user clicks on the Submit button:

<form method="post" action="welcome.asp">


First Name: <input type="text" name="fname" value="">
Last Name: <input type="text" name="lname" value="">
<input type="submit" value="Submit">
</form>

Retrieve the values in the "welcome.asp" file like this:


<%
fname=Request.form("fname")
lname=Request.form("lname")
response.write("<p>Hello " & fname & " " & lname & "!</p>")
response.write("<p>Welcome to my Web site!</p>")
%>
  !D.:

‡ What if a Browser Does NOT Support


Cookies?
‡ Add parameters to a URL
‡ Use a form
Day9
  ,
‡When you are working with an application, you open it, do some
changes and then you close it. This is much like a Session. The
computer knows who you are. It knows when you start the
application and when you end. But on the internet there is one
problem: the web server does not know who you are and what
you do because the HTTP address doesn't maintain state.
‡ASP solves this problem by creating a unique cookie for each
user. The cookie is sent to the client and it contains information
that identifies the user. This interface is called the Session object.
‡The Session object is used to store information about, or change
settings for a user session. Variables stored in the Session object
hold information about one single user, and are available to all
pages in one application. Common information stored in session
variables are name, id, and preferences. The server creates a new
Session object for each new user, and destroys the Session object
when the session expires.
|    $

A session starts when:


‡A new user requests an ASP file, and
the Global.asa file includes a
Session_OnStart procedure
‡A value is stored in a Session variable
‡A user requests an ASP file, and the
Global.asa file uses the <object> tag to
instantiate an object with session scope
|  u$
A session ends if a user has not requested or refreshed a
page in the application for a specified period. By default, this
is 20 minutes.
If you want to set a timeout interval that is shorter or longer
than the default, you can set the   property.
The example below sets a timeout interval of 5 minutes:
<%
Session.Timeout=5
%>
To end a session immediately, you may use the A
method:
<%
Session.Abandon
%>
 0  è 

The most important thing about the Session object is


that you can store variables in it.
<%
Session("username")="Donald Duck"
Session("age")=50
%>

When the value is stored in a session variable it can


be reached from ANY page in the ASP application:

ðJ=  5     J


0  è 
The Contents collection contains all session variables.
It is possible to remove a session variable with the Remove
method.
<%
If Session.Contents("age")<18 then
Session.Contents.Remove("sale")
End If
%>

To remove all variables in a session, use the RemoveAll method:


<%
Session.Contents.RemoveAll()
%>

   

The Contents collection contains all session variables.


You can loop through the Contents collection, to see
what's stored in it:
<%
Session("username")="Donald Duck"
Session("age")=50
dim i
For Each i in Session.Contents
Response.Write(i & "<br />")
Next
%>
u am
If you do not know the number of items in the
Contents collection, you can use the Count property:
<%
dim i
dim j
j=Session.Contents.Count
Response.Write("Session variables: " & j)
For i=1 to j
Response.Write(Session.Contents(i) & "<br
/>")
Next
%>
%,
You can loop through the StaticObjects collection, to
see the values of all objects stored in the Session
object:
<%
dim i
For Each i in Session.StaticObjects
Response.Write(i & "<br />")
Next
%>
ra
 Œ
1
‡ Write a program to return session id
number for a user
‡ Write a program to get a session's timeout
  !D.-

/ !

 ) 
/ 8 
!

 !  K
/ 8 
!

 0 K
/ !  +  !

 F ÷

/ +!

 F ÷

/ #  % 
%÷÷ 
/ 0÷
/ !  4)
%÷÷ 
/ 2 ÷!


Day+:
 @#!
The Global.asa file is an optional file that can contain
declarations of objects, variables, and methods that
can be accessed by every page in an ASP application.
All valid browser scripts (MavaScript, VBScript, MScript,
PerlScript, etc.) can be used within Global.asa.
The Global.asa file can contain only the following:
‡Application events
‡Session events
‡<object> declarations
‡TypeLibrary declarations
‡the #include directive
u@#
In Global.asa you can tell the application and session objects what
to do when the application/session starts and what to do when the
application/session ends. The code for this is placed in event
handlers. The Global.asa file can contain four types of events:
AA%   - This event occurs when the FIRST user
calls the first page from an ASP application. This event occurs after
the Web server is restarted or after the Global.asa file is edited.
The "Session_OnStart" event occurs immediately after this event.
A%   - This event occurs EVERY time a NEW user
requests his or her first page in the ASP application.
A%u - This event occurs EVERY time a user ends a
session. A user ends a session after a page has not been requested
by the user for a specified time (by default this is 20 minutes).
AA%u - This event occurs after the LAST user has
ended the session. Typically, this event occurs when a Web server
stops. This procedure is used to clean up settings after the
Application stops, like delete records or write information to text
files.
Πr r E aa a

<script language="vbscript" runat="server">


sub Application_OnStart
'some code
end sub
sub Application_OnEnd
'some code
end sub
sub Session_OnStart
'some code
end sub
sub Session_OnEnd
'some code
end sub
</script>
Sample Global.asa file
<script language="vbscript" runat="server">
Sub Application_OnStart
Application("visitors")=0
End Sub
Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock
End Sub
</script>
u am
To display the number of current visitors in an ASP
file:
<html>
<head>
</head>
<body>
<p>
There are
<%response.write(Application("visitors"))%>
online now!
</p>
</body>
</html>
0 

Restrictions on what you can include in the Global.asa


file:
‡You can not display text that is written in the
Global.asa file. This file can't display information
‡You can only use Server and Application objects in
the Application_OnStart and Application_OnEnd
subroutines.
‡In the Session_OnEnd subroutine, you can use
Server, Application, and Session objects. In the
Session_OnStart subroutine you can use any built-in
object
  !D/2

/,÷÷
 ÷
/0
 ,÷÷

/!  L ÷÷
M
/!÷,÷÷
 ÷
/+
 

Day+
A%,
‡An application on the Web may be a group of ASP
files. The ASP files work together to perform some
purpose. The Application object in ASP is used to tie
these files together.
‡The Application object is used to store and access
variables from any page, just like the Session object.
The difference is that ALL users share one Application
object, while with Sessions there is one Session
object for EACH user.
‡The Application object should hold information that
will be used by many pages in the application (like
database connection information). This means that
you can access the information from any page. It
also means that you can change the information in
one place and the changes will automatically be
reflected on all pages.
 0 Aè 

Application variables can be accessed and changed by


any page in the application.
You can create Application variables in "Global.asa"
like this:
<script language="vbscript" runat="server">

Sub Application_OnStart
application("vartime")=""
application("users")=1
End Sub

</script>
0 Aè 

You can access the value of an Application


variable like this:
There are
<%
Response.Write(Application("users"))
%>
active connections.

The Contents collection contains all application variables. You can loop through the
Contents collection, to see what's stored in it:
<%
dim i
For Each i in Application.Contents
Response.Write(i & "<br />")
Next
%>

If you do not know the number of items in the Contents collection, you can use the
Count property:
<%
dim i
dim j
j=Application.Contents.Count
For i=1 to j
Response.Write(Application.Contents(i) & "<br />")
Next
%>
%,

You can loop through the StaticObjects collection,


to see the values of all objects stored in the
Application object:
<%
dim i
For Each i in Application.StaticObjects
Response.Write(i & "<br />")
Next
%>

 º
You can lock an application with the "Lock" method.
When an application is locked, the users cannot
change the Application variables (other than the one
currently accessing it). You can unlock an application
with the "Unlock" method. This method removes the
lock from the Application variable:
<%
Application.Lock
'do some application object operations
Application.Unlock
%>
 BD 
You can insert the content of one ASP file into another ASP file before
the server executes it, with the #include directive. The #include
directive is used to create functions, headers, footers, or elements that
will be reused on multiple pages.

º BD 

Here is a file called "mypage.asp":


<html>
<body>
<h3>Words of Wisdom:</h3>
<p><!--#include file="wisdom.inc"--></p>
<h3>The time is:</h3>
<p><!--#include file="time.inc"--></p>
</body>
</html>

Here is the "wisdom.inc" file:


"One should never increase, beyond what is necessary,
the number of entities required to explain anything."

Here is the "time.inc" file:


<%
Response.Write(Time)
%>
) 1

If you look at the source code in a browser, it will look


something like this:
<html>
<body>
<h3>Words of Wisdom:</h3>
<p>"One should never increase, beyond what is
necessary,
the number of entities required to explain
anything."</p>
<h3>The time is:</h3>
<p>11:33:42 AM</p>
</body>
</html>
ra
 Œ
1
‡ Uppercase or lowercase a string
‡ Trim a string
‡ How to reverse a string?
‡ How to round a number?
  !D/.

/  
   

/    
   
/   
   
/ Ñ   Ñ 
 
/   

Ñ 
 
/ 


/  

 

/  

  
Day++
4  D% Y
D% Y 4 A '#  
4  A '#

4  D% Y

‡CDO (Collaboration Data Objects) is a Microsoft technology that


is designed to simplify the creation of messaging applications.
‡CDOSYS is a built-in component in ASP. We will show you how
to use this component to send e-mail with ASP.
D%N

Microsoft has discontinued the use of CDONTs on Windows 2000,


Windows XP and Windows 2003. If you have used CDONTs in
your ASP applications, you should update the code and use the
new CDO technology.
Sending a text e-mail:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>
Sending a text e-mail with Bcc
and CC fields:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.Bcc="someoneelse@somedomain.com"
myMail.Cc="someoneelse2@somedomain.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>
Sending an HTML e-mail:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.HTMLBody = "<h1>This is a
message.</h1>"
myMail.Send
set myMail=nothing
%>
Sending an HTML e-mail that sends
a webpage from a website:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.CreateMHTMLBody
"http://www.w3schools.com/asp/"
myMail.Send
set myMail=nothing
%>
Sending a text e-mail with an Attachment:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.AddAttachment
"c:\mydocuments\test.txt"
myMail.Send
set myMail=nothing
%>
ra
 Œ
1
‡ Write a program to send a mail
‡ Write a program to send a HTML mail
‡ Write a program to send a mail with attachment
‡ Sending a text e-mail with Bcc and CC fields
  !D//

/   Ñ 


/   
/     

ÑÑ  
/ 
/        
  
/      
 
/  

  
Day+/
    %,
The TextStream object is used to access the contents of
text files.
The following code creates a text file (c:\test.txt) and then
writes some text to the file (the variable f is an instance of
the TextStream object):
<%
dim fs, f
set
fs=Server.CreateObject("Scripting.FileSystemObject
")
set f=fs.CreateTextFile("c:\test.txt",true)
f.WriteLine("Hello World!")
f.Close
set f=nothing
set fs=nothing
%>
u 
The ReadAll method of the TextStream Object reads from the
opened text file

<html>
<body>
<p>This is the text in the text file:</p>
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")

Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
Response.Write(f.ReadAll)
f.Close

Set f=Nothing
Set fs=Nothing
%>
</body>
</html>
u 
read one line from a TextStream file.

<html>
<body>
<p>This is the first five characters from the text file:</p>

<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")

Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
Response.Write(f.Read(5))
f.Close

Set f=Nothing
Set fs=Nothing
%>

</body>
</html>
A0  

The ASP AdRotator component creates an


AdRotator object that displays a different image
each time a user enters or refreshes a page. A
text file includes information about the images.

>
ar a r# r rr a -  &$Œ|)* a r$(
ar a r  r
m  &$ 
  $(
>
u 
a file called "banners.asp".

 m
y
>
ar a r#Œ r r)r a -  &$Œ|)* a r$(
r  r
&ar a r  r
m  &$a  $((
>
.y
. m
) 1
The file "ads.txt" looks like this
?
/  

 ../  m.
V

|/Œ
7:
m
r  

 ..m
r  m.
V


r 
+:
The lines below the asterisk in the file "ads.txt" specifies
the images to be displayed, the hyperlink addresses, the
alternate text (for the images), and the display rates in percent
of the hits. We see that the W3Schools image will be displayed
for 80 % of the hits and the Microsoft image will be displayed
for 20 % of the hits in the text file above.
) 1
To get the links to work when a user clicks on them, we will have to
modify the file "ads.txt" a bit:
*uD]*u)a r a 
?
/  

 ../  m.
V

|/Œ
7:
m
r  

 ..m
r  m.
V


r 
+:
The redirection page (banners.asp) will now receive
a querystring with a variable named URL containing
the URL to redirect to.
ra
 Œ
1
‡ Write a program to read textfile
‡ Write a program to read only a part of a textfile
‡ Write a program to read one line of a textfile
‡ Write a program to read all lines from a textfile
  !D/7

/    

/  Ñ  
/ 

  
Day+0
 AD%

AD%
!   #
| AD%$

‡ADO is a Microsoft technology


‡ADO stands for ActiveX Data %bjects
‡ADO is a Microsoft Active-X component
‡ADO is automatically installed with
Microsoft IIS
‡ADO is a programming interface to
access data in a database
AD!  
A ''
The common way to access a database
from inside an ASP page is to:
1.Create an ADO connection to a database
2.Open the database connection
3.Create an ADO recordset
4.Open the recordset
5.Extract the data you need from the
recordset
6.Close the recordset
7.Close the connection
AD%D

&! 
!  
 
 #
 D N4D


‡The easiest way to connect to a database is to use a DSN-


less connection. A DSN-less connection can be used against
any Microsoft Access database on your web site.
‡If you have a database called "northwind.mdb" located in a
web directory like "c:/webdata/", you can connect to the
database with the following ASP code:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
%>
V  
 

 
    



 
 

 


 
   
 %D&D

If you have an ODBC database called "northwind" you can
connect to the database with the following ASP code:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "northwind"
%>
With an ODBC connection, you can connect to any database, on
any computer in your network, as long as an ODBC connection is
available.
A%D&
AD
Here is how to create a connection to a MS Access Database:
1. Open the %D& icon in your Control Panel.
2. Choose the  D N tab.
3. Click on Ain the System DSN tab.
8#  the Microsoft Access Driver. Click 3 #
5. In the next screen, click  to locate the database.
6. Give the database a Data ource Name (DSN).
7. Click %>.

Note that this configuration has to be done on the computer


where your web site is located. If you are running Personal
Web Server (PWS) or Internet Information Server (IIS) on
your own computer, the instructions above will work, but if
your web site is located on a remote server, you have to
have physical access to that server, or ask your web host to
do this for you.
 AD%%,
‡The ADO Connection Object is used to create an
open connection to a data source. Through this
connection, you can access and manipulate a
database.
‡If you want to access a database multiple times, you
should establish a connection using the Connection
object. You can also make a connection to a database
by passing a connection string via a Command or
Recordset object. However, this type of connection is
only good for one specific, single query.

<% 
 K5K -  B)-)H 
J
%,'  
'   D 

Attributes Sets or returns the attributes of a Connection object

CommandTimeout Sets or returns the number of seconds to wait while


attempting to execute a command

ConnectionString Sets or returns the details used to create a connection to a


data source
ConnectionTimeout Sets or returns the number of seconds to wait for a
connection to open

CursorLocation Sets or returns the location of the cursor service

DefaultDatabase Sets or returns the default database name

IsolationLevel Sets or returns the isolation level

Mode Sets or returns the provider access permission

Provider Sets or returns the provider name

State Returns a value describing if the connection is open or


closed
Version Returns the ADO version number
%,  

  D 

BeginTrans Begins a new transaction

Cancel Cancels an execution

Close Closes a connection

CommitTrans Saves any changes and ends the current transaction

Execute Executes a query, statement, procedure or provider specific


text
Open Opens a connection

OpenSchema Returns schema information from the provider about the


data source
RollbackTrans Cancels any changes in the current transaction and ends
the transaction
%,u

u D 

BeginTransComplete Triggered after the BeginTrans operation

CommitTransComplet Triggered after the CommitTrans operation


e
ConnectComplete Triggered after a connection starts

Disconnect Triggered after a connection ends

ExecuteComplete Triggered after a command has finished executing

InfoMessage Triggered if a warning occurs during a ConnectionEvent


operation
RollbackTransComplet Triggered after the RollbackTrans operation
e
WillConnect Triggered before a connection starts

WillExecute Triggered before a command is executed


ra
 Œ
1
‡ Write a program to display records
‡ Write a program to display records in an HTML
table
  !D/8

/ ] 
  
/     
/ 

    


/    Ñ 
 
/ Ñ  V   Ñ 
 
/ Ñ    Ñ  Ñ 
 
/   ÑÑ 
  

   
/   Ñ 
  

/ Ñ 
  
  
/ Ñ 
  
 
/ Ñ 
  
u
/  

  
Day+4
AD%0 
  
 ! 
 #
 AD%
0 
‡After an ADO Database Connection has been created, as
demonstrated in the previous chapter, it is possible to create an
ADO Recordset.
‡Suppose we have a database named "Northwind", we can get
access to the "Customers" table inside the database with the
following lines:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Customers", conn
%>
 AD% =

0 
We can also get access to the data in the "Customers"
table using SQL:

<%
set
conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
%>
u D!   
0 
‡After a recordset is opened, we can extract data from recordset.
‡Suppose we have a database named "Northwind", we can get access
to the "Customers" table inside the database with the following lines:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
for each x in rs.fields
response.write(x.name)
response.write(" = ")
response.write(x.value)
next
%>
AD%0 %,
‡The ADO Recordset object is used to hold a set of
records from a database table. A Recordset object
consist of records and columns (fields).
‡In ADO, this object is the most important and the
one used most often to manipulate data from a
database.

ðJ 
 = 5K -  B)-)H  J

‡When you first open a Recordset, the current record


pointer will point to the first record and the BOF and
EOF properties are False. If there are no records, the
BOF and EOF property are True.
AD%0 %, 1
Recordset objects can support two types
of updating:
‡  - all changes
are written immediately to the database
once you call the Update method.
‡&  - the provider will
cache multiple changes and then send
them to the database with the
UpdateBatch method.
AD%0 %, 1
In ADO there are 4 different cursor types defined:
‡D   - Allows you to see additions, changes, and deletions
by other users.
‡>  4 Like a dynamic cursor, except that you cannot see
additions by other users, and it prevents access to records that other
users have deleted. Data changes by other users will still be visible.
‡   - Provides a static copy of a recordset for you to use to
find data or generate reports. Additions, changes, or deletions by other
users will not be visible. This is the only type of cursor allowed when
you open a client-side Recordset object.
‡3  4  - Allows you to only scroll forward through the
Recordset. Additions, changes, or deletions by other users will not be
visible.
The cursor type can be set by the CursorType property or by the
CursorType parameter in the Open method.
N( Not all providers support all methods or properties of the
Recordset object.
ra
 Œ
1
‡ Write a program to display records using recordset
object
‡ Write a program to display records in an HTML
table using recordset object
  !D/9

/ -14+ 

/ %  -14÷+ 

/ %  -14!N#+ 

/ 0  1  + 

/ -14+ 
 4)
/ 2 ÷!


Day+5
AD%0 4'  
'   D 
AbsolutePage Sets or returns a value that specifies the page number in
AbsolutePosition the
SetsRecordset
or returnsobject
a value that specifies the ordinal position of
the current record in the Recordset object
ActiveCommand Returns the Command object associated with the
Recordset
ActiveConnection Sets or returns a definition for a connection if the
connection is closed, or the current Connection object if
BOF the connection
Returns is open
true if the current record position is before the
Bookmark first
Sets record, otherwise
or returns false The bookmark saves the
a bookmark.
CacheSize position of the current
Sets or returns record
the number of records that can be cached
CursorLocation Sets or returns the location of the cursor service

CursorType Sets or returns the cursor type of a Recordset object


DataMember Sets or returns the name of the data member that will be
retrieved from the object referenced by the DataSource
DataSource property
Specifies an object containing data to be represented as a
EditMode Recordset object
Returns the editing status of the current record
AD%0 C'  ##
EOF Returns true if the current record position is after the last record, otherwise false
Filter Sets or returns a filter for the data in a Recordset object
Index Sets or returns the name of the current index for a Recordset object
LockType Sets or returns a value that specifies the type of locking when editing a record in a
Recordset
MarshalOpti Sets or returns a value that specifies which records are to be returned to the server
ons
MaxRecords Sets or returns the maximum number of records to return to a Recordset object
from a query
PageCount Returns the number of pages with data in a Recordset object
PageSize Sets or returns the maximum number of records allowed on a single page of a
Recordset object
RecordCount Returns the number of records in a Recordset object
Sort Sets or returns the field names in the Recordset to sort on
Source Sets a string value or a Command object reference, or returns a String value that
indicates the data source of the Recordset object
State Returns a value that describes if the Recordset object is open, closed, connecting,
executing or retrieving data
Status Returns the status of the current record with regard to batch updates or other bulk
operations
StayInSync Sets or returns whether the reference to the child records will change when the
parent record position changes

AD%0 C
 D 
 
AddNew Creates a new record
Cancel Cancels an execution
CancelBatch Cancels a batch update
CancelUpdate Cancels changes made to a record of a Recordset object

Clone Creates a duplicate of an existing Recordset


Close Closes a Recordset
CompareBookmarks Compares two bookmarks
Delete Deletes a record or a group of records
Find Searches for a record in a Recordset that satisfies a
GetRows specified criteriarecords from a Recordset object into a
Copies multiple
GetString two-dimensional
Returns a Recordsetarray
as a string
Move Moves the record pointer in a Recordset object
MoveFirst Moves the record pointer to the first record
MoveLast Moves the record pointer to the last record
MoveNext Moves the record pointer to the next record
MovePrevious Moves the record pointer to the previous record
AD%0 C  1
NextRecor Clears the current Recordset object and returns the next Recordset
dset object by looping through a series of commands
Open Opens a database element that gives you access to records in a table,
the results of a query, or to a saved Recordset
Requery Updates the data in a Recordset by re-executing the query that made
the original Recordset
Resync Refreshes the data in the current Recordset from the original database
Save Saves a Recordset object to a file or a Stream object
Seek Searches the index of a Recordset to find a record that matches the
specified values
Supports Returns a boolean value that defines whether or not a Recordset object
supports a specific type of functionality
Update Saves all changes made to a single record in a Recordset object
UpdateBa Saves all changes in a Recordset to the database. Used when working
tch in batch update mode
AD%0 C u
u D 
EndOfRecordset Triggered when you try to move to a record after the last
record
FetchComplete Triggered after all records in an asynchronous operation
have been fetched
FetchProgress Triggered periodically in an asynchronous operation, to
state how many more records that have been fetched
FieldChangeComplete Triggered after the value of a Field object change

MoveComplete Triggered after the current position in the Recordset has


changed
RecordChangeComplete Triggered after a record has changed

RecordsetChangeComplet Triggered after the Recordset has changed


e
WillChangeField Triggered before the value of a Field object change
WillChangeRecord Triggered before a record change
WillChangeRecordset Triggered before a Recordset change

WillMove Triggered before the current position in the Recordset


changes
AD%0 C 
 D 
Fields Indicates the number of Field objects in the Recordset
object
Properties Contains all the Property objects in the Recordset object
 3D
'  

'   D 


Count Returns the number of items in the fields
collection. Starts at zero.
Example:
countfields = rs.Fields.Count

Item(named_item/num Returns a specified item in the fields collection.


ber) Example:
itemfields = rs.Fields.Item(1)
or
itemfields = rs.Fields.Item("Name")
  !D/;

/ 
    
/ 
   
/ 
   u
/ 
   Ñ 
 
Day+'
AD%D
   !    
 
#

u 
‡D  
How to first create a database connection, then a recordset, and
then display the data in HTML.
‡D  

How to display the data from the database table in an HTML
table.
‡A   

How to add headers to the HTML table to make it more readable.
‡A  

How to add colors to the HTML table to make it look nice.
u am ! Display records
How to first create a database connection, then a recordset, and then display the data in
HTML.

<html> <body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Met.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn

do until rs.EOF
for each x in rs.Fields
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value U "<br />")
next
Response.Write("<br />")
rs.MoveNext
loop

rs.close
conn.close
%>
</body> </html>
u am + !Display records in an HTML table
How to display the data from the database table in an HTML table.
ð 
ð 

ð
 
  Ñ   
   Ñ 
  !

   
"  u #$

        !!

    Ñ   
    
  !
  uuÑÑ  %Ñ  
 Ñ  %



ð    &    &$$ 


ð   u 
ð 
ð 
  
ð ð    !ð 
ð
 V 
ð 
ð

 


 

ð 

ð 
ð 
   ! Add headers to the HTML table
How to add headers to the HTML table to make it more readable.

<html> <body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Met.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT Companyname, Contactname FROM Customers"
rs.Open sql, conn
%>

<table border="1" width="100%">


<tr>
<%for each x in rs.Fields
response.write("<th>" U x.name U "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body> </html>
  !Add colors to the HTML table
How to add colors to the HTML table to make it look nice.
<html><body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Met.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT Companyname, Contactname FROM Customers"
rs.Open sql, conn
%>

<table border="1" width="100%" bgcolor="#fff5ee">


<tr>
<%for each x in rs.Fields
response.write("<th align='left' bgcolor='#b0c4de'>" U x.name U "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body></html>
  !Display records where "Companyname" starts with an A
How to display only the records from the "Customers" table that have
a "Companyname" that starts with an A.
 ÷
O
   <!% 4) $=-141.%   =&
 2 <= 
   4#01.>?=
 4 = 3 3   =

 
<!% 4) $=-141. 
 =&

'÷<=!0#0%%  %  *+4%


8"0+0% :#] 07-O7=



4 
'÷ 
O
 ÷<=6=  <=6??O=
 
O  
* ÷



 $= =P P=3 =&
 O3 
O ÷
04*O
 
O  
* ÷
O
 O+

8 $÷&O3 
O 

: O
3 
O÷

 ÷

  ÷
O3 ÷33 ÷
  !Sort the records on a specified fieldname ascending
How to sort the data on a specified fieldname.
 ÷
O

   <!% 4) $=-141.%   =&
 2 <= 
   4#01.>?=
 4 = 3 3   =

 
<!% 4) $=-141. 
 =&

'÷<=!0#0%%  %  *+4
%

4+10+.5% :=

4 
'÷ 
O
 ÷<=6=  <=6??O= 
O  
* ÷



 $= =P P=3 =&
 O3 
O ÷
04*O
 
O  
* ÷
O
 O+

8 $÷&O3 
O 

: O
3 
O÷

 ÷

  ÷
O
3 ÷33 ÷

  

‡ Display records where "Companyname" is > E
How to display only the records from the "Customers" table
that have a "Companyname" that is larger than E.
‡ Display only Spanish customers
How to display only the Spanish customers from the
"Customers" table.
‡ Let the user choose filter
Let the user choose which country to show customers from.
‡ Sort the records on a specified fieldname ascending
How to sort the data on a specified fieldname.
‡ Sort the records on a specified fieldname descending
How to sort the data on a specified fieldname.
‡ Let the user choose what column to sort on
  !D/?

/   
/ u & 1
÷ 

/ u '1
÷ 
  "# ÷
" 
÷    
 ÷  "# ÷
/ u (  -
  "# ÷
" 
  "# ÷  ÷
/ u #- ÷
  "# ÷
"  ÷
  "# ÷  ÷ 
/ u )1
÷ 
=%  =

  
-" 
÷ ÷  
 =%

= ÷  
=%  =  

  -
/ u *!   
 
   ÷ 
 
" 
    
   ÷ 
/  
   
Day+7
AD%A0 
‡We may use the SQL INSERT INTO
command to add a record to a table in a
database
‡Add a Record to a Table in a Database
‡We want to add a new record to the
Customers table in the Northwind
database. We first create a form that
contains the fields we want to collect
data from.
ð 
u am ! -rm
ð
ð  
      
 
ð
ð
ð

ð
ðð   
  ð
ðð
ð
  ð
ðð      ð
ðð
ð
   ð
ðð       ð
ðð
ð 

ð
ðð    

ð
ðð
ð
ð
ðð     ð
ðð
ð

ð
ðð    
  ð
ðð
ð
 ð
ðð      ð
ð
ð
ðð
ð  
      
ð   
  
  
ð
ð
ð 
   

When the user presses the submit button the


form is sent to a file called "demo_add.asp".
The "demo_add.asp" file contains the code
that will add a new record to the Customers
table:
demo_add.asp
 ÷
O

   <!% 4) $=-141.%   =&


 2 <= 
   4#01.>?=
 4 = 3 3   =

'÷<=]:!0+]:4 

$ 
]1   =

'÷<
'÷P=   

 
÷   &=

'÷<
'÷P=F-#90!=

'÷<
'÷P=$7=P+'
*$= 
=&P=7=

'÷<
'÷P=7=P+'
*$=  =&P=7=

'÷<
'÷P=7=P+'
*$=  =&P=7=

'÷<
'÷P=7=P+'
*$=

=&P=7=

'÷<
'÷P=7=P+'
*$= =&P=7=

'÷<
'÷P=7=P+'
*$=
=&P=7=

'÷<
'÷P=7=P+'
*$=  =&P=7&=
 
 
 0  
'÷  
? 
+

8 $=: 


Q=&


+

8 $=C=P  P= 3C=&
  
  ÷

O33 ÷
  
If you use the SQL INSERT command be
aware of the following:
‡If the table contains a primary key, make
sure to append a unique, non-Null value to the
primary key field (if not, the provider may not
append the record, or an error occurs)
‡If the table contains an AutoNumber field, do
not include this field in the SQL INSERT
command (the value of this field will be taken
care of automatically by the provider)
| 3| D$
In a MS Access database, you can enter zero-
length strings ("") in Text, Hyperlink, and
Memo fields IF you set the AllowZeroLength
property to Yes.
N( Not all databases support zero-length
strings and may cause an error when a record
with blank fields is added. It is important to
check what data types your database
supports.
AD%º0 
|   =
º'DAu
   
#
º0 
‡We want to update a record in the Customers table in the Northwind database.
We first create a table that lists all records in the Customers table:

<html> <body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM customers",conn
%>
<h2>List Database</h2>
<table border="1" width="100%">
<tr>
<%
for each x in rs.Fields
response.write("<th>" & ucase(x.name) & "</th>")
Next %>
º0 contd·
3 
O ÷
04*O
 
 <=
=  <=R 
=
O
  
* ÷

÷ 
$ &<= 
 =  O
 
   <=
 = <= 
]1=÷<=O<÷O=
3 
O÷
O
 O+

8 $÷&O3 
O  

O
3
O
: O
3 
O
÷
  ÷

O
3 ÷
33 ÷
º0 contd·
If the user clicks on the button in the "customerID" column he or she will be
taken to a new file called "demo_update.asp". The "demo_update.asp" file
contains the source code on how to create input fields based on the fields from
one record in the database table. It also contains a "Update record" button that
will save your changes:
 ÷
E9 + 3E
O

   <!% 4) $=-141.%   =&
 2 <= 
   4#01.>?=
 4 = 3 3   =
<+'
*$= 
]1=&
+'
$=   =&<== 

 
<!% 4) $=-141.+ 
 =&

 =!0#0%S*+4 

8"0+0 
]1<7=P P=7= 
O
 <=
=  <=R 
=
 ÷
O  
* ÷
O
 
 O< O3 
    <=O< O=÷<=O<÷O=3 
O  O
3 
3 ÷
33
   <=
 =÷<=9  =3
º0 contd·
<%
else
sql="UPDATE customers SET "
sql=sql & "companyname='" & Request.Form("companyname") & "',"
sql=sql & "contactname='" & Request.Form("contactname") & "',"
sql=sql & "address='" & Request.Form("address") & "',"
sql=sql & "city='" & Request.Form("city") & "',"
sql=sql & "postalcode='" & Request.Form("postalcode") & "',"
sql=sql & "country='" & Request.Form("country") & "'"
sql=sql & " WHERE customerID='" & cid & "'"
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.write("Record " & cid & " was updated!")
end if
end if
conn.close
%>
</body> </html>

  

‡ |     0 
‡ |    0 

  !D/:

/  

/ u   
/  +
/ ] 
/         
/    

/   

/  

  
Day+9
AD%D0 
|   =
Du
uu
   
#
D0 
We want to delete a record in the Customers table in the Northwind
database. We first create a table that lists all records in the
Customers table:
<html> <body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM customers",conn
%>
<h2>List Database</h2>
<table border="1" width="100%">
<tr>
<%
for each x in rs.Fields
response.write("<th>" & ucase(x.name) & "</th>")
next
%> </tr>
D0 contd..
O ÷
04*O
 
 <=
=  <=R÷ 
=
O
  
* ÷

 <= 
]1=  O
 
   <=
 = <= 
]1=÷<=O<÷O=
3 
O÷
O
 O+

8 $÷&O3 
O  

O
3
O
: O
3 
O
÷
  ÷

O
3 ÷33 ÷
D0 contd..
If the user clicks on the button in the "customerID" column he or she will be
taken to a new file called "demo_delete.asp". The "demo_delete.asp" file contains
the source code on how to create input fields based on the fields from one record
in the database table. It also contains a "Delete record" button that will delete the
current record:

<html>
<body>
<h2>Delete Record</h2>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
cid=Request.Form("customerID")
if Request.form("companyname")="" then
set rs=Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM customers WHERE customerID='"
& cid & "'",conn
%>
D0 contd..
 <=
=  <=R÷ 
=
 ÷
O  
* ÷
O
 
 O< O3 
    <=O< O=÷<=O<÷O=3 
O  O
3 
3 ÷
33
   <=
 =÷<=1÷  =
3
O



'÷<=10#00*+4 

=

'÷<
'÷P=8"0+0 
]1<7=P P=7=
 
 
 0  

? 


 $=: 


Q=&




 $=+ =P P=
÷ Q=&
  
  
  ÷

O33 ÷
  4  !
 A$

‡Open Windows Explorer, find the .mdb file.


Right-click on the .mdb file and select
Properties. Go to the Security tab and set the
access-rights here.
  !D/-

/   

/  

/   
 

      

 
  
Day/:!* 


Вам также может понравиться