Академический Документы
Профессиональный Документы
Культура Документы
Thi, i, to /ertif* that the pra/ti/al file o PROGRA%%ING IN C Submitted to P$N&AB TECHNICAL $NI'ERSIT( &ALAN#ER I partial fulfillme t to the re9uireme t for the a!ard of the de"ree of
The matter embodied i thi, pra/ti/al file i, a "e ui e !or4 do e B* the ,tude t)
A/4 o!led"eme t
O e e5er* ,tep there i, a eed of "uida /e; ,upport a d moti5atio ) Thi, e /oura"e, the per,o to "i5e their be,t performa /e a d help i rea/hi " their "oal,) Thi, file i, e,,e tiall* prepared i the partial fulfillme t of the pra/ti/al file of the POST GRA#$ATE #IPLO%A IN CO%P$TER
APPLICATION e<ami atio ) We !i,h to ta4e thi, opportu it* to e<pre,, our
"ratitude to all tho,e !ho ha5e dire/tl* or i dire/tl* helped u, i /ompleti " thi, file)
Fir,t of all !e !ould li4e to tha 4 our /o+ordi ator =S)%AN&IT SINGH CHHABRA> for helpi " a, the be,t fa/ilitie, a5ailable i moti5ati " u, at e5er* ,tep the ) We !ould li4e to tha 4 our Sub.e/t Guide =G$RLEEN 0A$R> !ho purpo,ed u, thi, file a d pro5ided u, !ith her 5aluable "uida /e; e /oura"eme t a d ,u""e,tio , throu"hout the period till /ompletio )
I de<
S)No
#e,/riptio
Page
8 6 A 1 2 B C 3 D 87 88 86 8A 81 82 8B 8C 83
INTRODUCATION OF HTML THE STUUCTURE OF AN HTML PROGRAM DOCUMENT HEAD EMPHASIZING MATERIAL IN WEB PAGE LISTS IMAGE TAG PROGRAM OF INSERTING IMAGE TABLES LINKING DOCUMENT FRAMES INTRODUCTION TO JAVASCRIPT PROGRAM OF USING VARIABLE IN JAVA SCRIPT FUNCTION IN JAVASCRIPT THE &A'A SCRIPT #OC$%ENT OB&ECT %O#E PROGRA% OF CREAT A FOR% COO0IES PROGRA% OF $SING F$NCTION
2 3 88 8C 67 66 6A 6D A6 A1 AB
18 1B 48
50 52
INTRO#$CTION OF HT%L
H*per Te<t %ar4up La "ua"e i, a ,et of ,pe/ial /ode, !here ordi ar* te<t /a be /o 5erted i to h*perte<t) The,e /ode, are u,ed to /o trol the la*out a d appeara /e, to the te<t o HT%L pa"e) HT%L i, ot a pro"rammi " la "ua"e) It
/ombi e, the i ,tru/tio , !ithi data to tell a di,pla* pro"ram /alled bro!,er; ho! to re der the data that the do/ume t /o tai ,)
Bro!,e Cli t
Web Ser5er
#efi itio ?
The la "ua"e u,ed to de5elop !eb pa"e i, /alled H*per Te<t %ar4up La "ua"e) HT%L i, a la "ua"e i terpreted b* a bro!,er) Web pa"e, al,o /alled HT%L do/ume t,)HT%L i, a ,et of /ode, that /a be embedded i te<t to add formatti " a d li 4i " i formatio ) HT%L i, ,pe/ified a, ta", i a HT%L do/ume t)
HT%L Editor,
There are a umber of HT%L editor, a5ailable for /reati " !eb pa"e,) Abode Pa"e %ill+ A editor that help, automate the !hole pro/e,, of ,ite de,i" a d impleme tatio ) AllaireE, Home Site + A ,imple; but po!erful editor) Ama*a + AW(SIW(G F!hat *ou ,ee i, !hat *ou "etG HT%L editor from WA Corporatio ) Ameri/a C*ber eti/, %ulti+EditA pro"rammer,) HT%L editor that !or4, !ell for
BBEdit + A ea,*+to+u,e %a/i to,h HT%L editor) Clari, Home Pa"e+ A editor !ith mo,tl* W(SIW(G for be"i ,ome additio al tool,)
6
er, !ith
Hot #o" Pro+ Amore po!erful 5er,io of the Hot #o" E<pre,, editor i /lude ma * ad5a /ed featured; ,u/h a, ,ite ma a"eme t) Hot%etal Pro+ A e<te ,i5e; po!erful a d 5e erated HT%L editor) %i/roEd"eE, 'i,ual Sli/4Edit+ A editor that !or4, !ell for pro"rammer,) It let, *ou !or4 fa,ter tha ma * "raphi/+ba,ed editor,) %i/ro,oft Fro tpa"e+ A editor /o tai ed i i te"rate, dire/tl* !ith *our Web ,ite) a po!erful pa/4a"e that the Net,/ape
Net,/ape Compo,er+ A editor that /ome, !ith Commu i/ator; more or le,, W(SIW(G) It i, ea,* to u,e)
HT%L Ta",
A HT%L ta" i, a ,i" al to a bro!,er that it ,hould do ,omethi " other tha .u,t thro! te<t up o the ,/ree ) B* /o 5e tio all HT%L ta", be"i !ith a ope a "le FIG a d e d !ith a /lo,e a "le bra/4et FJG) IHT%LJ I:HT%LJ HT%L ta", /a be of t!o t*pe, ?
7
Paired Ta", The IBJ ta" i, a paired ta" !ith it, /ompa io ta" I:BJ Si "ular The IBRJ ta" !ill i ,ert a li e brea4)
IHT%LJ
OUTPUT:
#o/ume t Head
The HT%L ta" i, u,ed to i di/ate the ,tart a d e d of the head ,e/tio are? IHEA#J ITITLEJ I:TITLEJ I:HEA#J #o/ume t Bod* Thi, pa"e u,ed to i di/ate the ,tart a d e d of mai bod* of te<tual i formatio are ? IBO#(J I:BO#(J
I:HEA#J IBO#(J Ih8J Pro.e/t o Global !armi " I:h8J Wel/ome to the home pa"e of the pro.e/t o Global !armi ") IpJ IulJ IliJIA HREFM>bur )html>JBur I:AJmore fore,t,) IliJ#e,tro* the IA HERFMhttp?::!ho)Ooo) do:oOo e)html>J OOo eI:AJla*er) IliJBirth more IA HERFM>ftp?foo)do)do:/o!,)"if>J/o!,I:aJ I:ulJ IBO#(J I:HT%LJ
Title, a d Footer,
Title Te<t i /luded bet!ee the ITITLEJ@@@))I:TITLEJ ta" ,ho! title bar of the bro!,er !i do!) Footer &u,t a, a title /a be pla/ed i the title bar of the bro!,er !i do!; /ertai i formatio i, /ommo l* pla/ed at the footer of the !eb pa"e) The HT%L ta", are? E<ample? IBO#(J IH8J Thi, i, HT%L Tutorial I:H8J
10
up i
@@@@@@@@@@)) @@@@@@@@@@)) IA##RESSJ thi, i, the footer di,pla*ed b* the A##RESS ta" I:A##RESSJ I:BO#(J
I:PJI:BO#(JIHT%LJ
#ra!i " Li e, The ta" IHRJ dra!, Li e, a d horiOo tal rule,) Thi, ta" dra!, a horiOo tal li e a/ro,, the !hole pa"e; !here5er ,pe/ified) Te<t St*le Bold #i,pla*ed te<t i BOL#FACE ,t*le) The ta", u,ed are IBJ@)I:BJ
IBO#(J THIS IS A SI%PLE PROGA%E)INFOR%ATION PLACE# IN THIS SECTION ISESSENTIAL TO THE INNER WOR0ING OF THE #OC$%ENT AN# HAS NOTHING TO #O WITH THE CONTENT OF THE #OC$%ENT IBJ THIS IS A SI%PLE PROGA%E)INFOR%ATION PLACE# IN THIS SECTION IS ESSENTIAL TO THE INNER WOR0ING OF THE #OC$%ENT AN# HAS NOTHINTO #O WITH THE CONTENT OF THE #OC$%ENT I:BJ I:BO#(J IHT%LJ OUTPUT:
THIS IS A SI%PLE PROGA%E)INFOR%ATION PLACE# IN THIS SECTION IS ESSENTIAL TO THE INNER WOR0ING OF THE #OC$%ENT AN# HAS NOTHING TO #O WITH THE CONTENT OF THE #OC$%ENTIBRJIBRJ IIJ THIS IS A SI%PLEPROGA%E)INFOR%ATION PLACE# IN THIS SECTION IS ESSENTIAL TO THE INNER WOR0ING OF THE #OC$%ENT AN# HAS NOTHING TO #O WITH THE CONTENT OF THE #OC$%ENT I:IJ I:BO#(J IHT%LJ OUTPUT:
I:HEA#J IBO#(J THIS IS A SI%PLE PROGA%E)INFOR%ATION PLACE# IN THIS SECTION IS ESSENTIAL TO THE INNER WOR0ING OF THE #OC$%ENT AN# HAS NOTHING TO #O WITH THE CONTENT OF THE #OC$%ENTIBRJIBRJ I$JIBJ THIS IS A SI%PLE PROGA%E)INFOR%ATION PLACE# IN THIS SECTION IS ESSENTIAL TO THE INNER WOR0ING OF THE #OC$%ENT AN# HAS NOTHING TO #O WITH THE CONTENT OF THE #OC$%ENT IBJI:$J I:BO#(J IHT%LJ OUTPUT:
Other Te<t Effe/t, ICENTERJ@))I:CENTERJ ta", are u,ed to /e ter e5er*thi " fou d bet!ee them+ te<t; Li,t; ima"e,; rule,; table,; or a * other pa"e eleme t) E<ample ICENTERJ Wel/ome to HT%L Pro"rammi " I:CENTER:J Output Wel/ome to HT%L Pro"rammi "
16
Spa/i " FI de ti " Te<tG The ta" u,ed for i ,erti " bla 4 ,pa/e i a HT%L do/ume t i, ISPACERJ) E<ample Hardeep /heemaIBRJ ISPACER T(PE M =HORINANTEL> SINE M D7J /heema Output Hardeep /heema Co trolli " Fo t SiOe a d Color All te<t ,pe/ified !ithi the ta", IFONTJ a d I:FONTJ !ill appear i the fo t; ,iOe a d /olor a, ,pe/ified a, attribute, of the ta" IFONTJ) PROGRA% IHT%LJ IHEA#J ITITLEJ TR(ING AT WRITING HT%L I:TITLEJ I:HEA#J IBO#( BG COLO$RMPERPAL TEPTMBL$EJ THIS IS &$ST A TRIAL TO CHEC0 O$T ALL THE HT%L TAGS) IBRJ IPJ
17
LISTS HT%L pro5ided ,er5er eleme t, for ma4i " li,t,) Thi, u it !ill pro5ide a i trodu/tio to the t*pe, of li,t, amel* the re"ular li,t u der !hi/h /ome, the ordered a d u ordered li,t a d the defi itio li,t or the "lo,,ar* li,t) T*pe, of li,t, $ ordered li,t? A u ordered li,t ,tart !ith ta", I$LJ a d, !ith I:$LJ) Ea/h li,t item ,tart !ith the ta" ILIJ) It i, a paired ta" F$LG) The attribute, that /a be ,pe/ified !ith ILIJ are)
IHT%LJ OUTPUT:
Ordered li,t? A ordered li,t ,tart, !ith the ta" IOLJ a d e d, !ithI:OLJ) Ea/h li,t item ,tart, !ith the ta" ILIJ) IOLJ i, al,o a paired ta")
#efi itio li,t? #efi itio li,t 5alue, appear !ith i ta", I#LJ a d e d, !ith I:#LJ)
IHT%LJ OUTPUT
Image tag
The Iim"J Ta" HT%L defi e, a ima"e ta" II%GJ that i, u,ed to pla/e ima"e, o the do/ume t) The ima"e /a be pla/ed !ith te<t a d he /e i that /ade it !ill be /alled a i li e ima"e) The ima"e t*pe, ,upported b* /ommo bro!,er, are )GIF a d )&PG) 'er* ba,i/ ,* ta< for II%GJ ta" i, a, follo!,? II%G SRCM =Ima"eName !ith relati5e path to the do/ume t>J E") II%GJ SCRM =flo!er )"if>J <!PROGRAM USING BACKGROUND IMAGE-- > IHT%LJ IHEA#J ITITLEJPAGEI:TITLEJ I:HEA#J IBO#( BAC0GRO$N#MQE?SWALLPAPERSflo!er,S8DA)&PGQJ THIS IS A SI%PLE PROGA%E)INFOR%ATION PLACE# IN THIS SECTION IS ESSENTIAL TO THE INNER WOR0ING OF THE #OC$%ENT
21
IN THIS SECTION IS ESSENTIAL TO THE INNER WOR0ING OF THE #OC$%ENTIBRJICENTERJ II%G SRCMQE?SWALLPAPERSHill,S%ou27a)&PGQ HEIGHTM677 WI#THMA77J I:CENTERJI:BO#(J IHT%LJ OUTPUT:
TABLES
A table i, a t!o dime ,io al matri<; /o ,i,ti " of ro!, a d /olum ,) Table, header are i te ded for di,pla*i " data i /olum , o a !eb pa"e) All table related ta", are i /lude bet!ee the ITABLEJ@))I:TABLEJta",) Ea/h /oloum of a
23
Table i, de,/ribed bet!ee the ITRJ I:TRJ ta",) Ea/h /olum of a table i, de,/ribed bet!ee the IT#J I:T#J ta",) T!o t*pe, of table ro!,? Header ro!, A table header ro! i, defi ed u,i " ITHJI:THJ ta",) The /o te t of a table header ro! i, automati/all* /e tered a d appear, i boldfa/e) #ata ro!, #ata /ell, hold data that mu,t be di,pla*ed i the table) Adata ro! i, defi ed u,i " ITRJ I:TRJ ta", ) Te<t matter di,pla*ed i data ro! i, left .u,tified b* default) A * ,pe/ial formatti " li4e boldfa/e or itali/, i, do e b* i /ludi " appropriate formati " ta", i ,ide the ITRJ I:TRJ ta",) The attribute, of ITABLEJ ta", are? Ali" + Left; Ce ter; Bottom) 'ali" + Top; Bottom; %iddle) Width+ Cellpadi "+ #i,ta /e bet!ee the data i a/ell or bou darie,) Cell,pa/i "+ Spa/i " bet!ee ad.a/e t /ell) Coll,pa + %ultiple /olum , /orre,po di " to o e /oloum) Ro!,pa + %ultiple ro!, /orre,po di " to o e /olum ,) Captio Ta" Ofte table, eed to be "i5e a readi " !hi/h "i5e, the reader a /o te<t for the i formatio i the table) It /a be pro5ided the table b* u,i " I/aptio J@@)I:/aptio J ta",) Ali" M It /o trol, pla/i " of the /aptio !ith re,pe/t to the table)
ITITLEJPAGEI:TITLEJ I:HEA#J IBO#( BGCOLORMORANGEJ ICENTERJ ITABLE BOR#ERM87J ITRJ ITHJ NA%E ITHJCLASS ITHJROLLNO I:TRJ ITRJ IT#JAARTI IT#JB)A) IT#J8 I:TRJ ITRJ IT#JA0HILESH IT#JB)A) IT#J6 ITRJ IT#JNEHA IT#J%)A) IT#JA I:TRJ ITRJ
25
<!PROGRAM OF ROWSPAN AND COLSPAN IN A TABLE-- > IHT%LJ IHEA#J ITITLEJTABLEI:TITLEJ I:HEA#J ITABLE BOR#ERM87 WI#THM27T ALIGNMCENTERJ ITRJ ITH ROWSPANM6JNA%E ITH COLSPANMAJ%AR0S I:TRJ ITRJ
26
ITHJ&A'A ITHJBASIC ITHJ'IS$AL I:TRJ ITRJ IT#JTAPES IT#J12 IT#J12 IT#J12 I:TRJ ITRJ IT#JNEHA IT#J18 IT#J13 IT#JC2 I:TRJ I:TABLEJ I:BO#(J I:HT%LJ OUTPUT:
27
BOR#ERM87
IT#JAARTI IT#JB)A) IT#J8 I:TRJ ITRJ IT#JA0HILESH IT#JB)A) IT#J6 ITRJ IT#JNEHA IT#J%)A) IT#JA I:TRJ ITRJ IT#J'INNI IT#J%)A IT#J1 I:TRJ I:TABLEJ I:CENTERJI:BO#(J IHT%LJ OUTPUT:
29
LIN0ING #OC$%ENT
While ,urfi " o the i ter et *ou mi"ht ha5e /ome a/ro,, ma * !eb li 4, that allo!ed .umpi " from o e !eb pa"e to a other or to a differe t ,e/tio of the ,ame !eb pa"e) If *ou are readi " thi, tutorial o5er i ter et the *ou mu,t ha5e u,ed ,ome li 4, o the pre5iou, pa"e, that brou"ht *ou o5er to thi, pa"e) The,e !eb li 4, are 4 o! a, H*perli 4, or Hot,pot,) Li 4, HT%L allo!, li 4i " to other HT%L do/ume t a, !ell a, Ima"e,) Cli/4i " o a ,e/tio of te<t or ima"e i o e !eb pa"e !ill ope a e tire !eb pa"e or a ima"e) The te<t or a ima"e that pro5ide, ,o li 4a"e, i, /alled H*per Te<t a h*perli 4 or hot,pot) Li 4, are /reated i a !eb pa"e b* u,i " the IAJ@))I:AJ ta",) A * thi ", !ritte bet!ee the IAJ ta" be/ome a h*perli 4 a5i"atio to a differe t !eb pa"e or ima"e tae pla/e) A do/ume t to be a5i"ator to eed to be ,pe/ified) B* u,i " the HREF attribute of the IAJ tab the e<t ima"e /a be ,pe/ified) S* ta<? IA HRefM =file ame)hlml>J H*perli 4, /a be of t!o t*pe,)
30
Li 4, to a e<ter al do/ume t) Li 4, to a ,pe/ifi/ pla/e !ith i the ,ame do/ume t) E<ter al #o/ume t Refere /e E<ample IA HREF M =detail, )html>J 'i,it m* Home Pa"e I:AJ I ter al #o/ume t Refere /e S* ta< IA NA%E M =lo/atio - ame>G IA HENF M =W lo/atio - ame>G @@) I:AJ
31
Ima"e, a, H*perli 4 &u,t a, /a a/t a, a h*perli 4; ,o al,o ima"e /a a/t a, h*perli 4,) E<ample IA HREF M =detail, )htmQJII%G SRC M =mi/4*)"if>J I:AJ Ima"e map, Whe a h*perli 4 i, /reated o a ima"e; /li/4i " o a * part of the ima"e !ill lead to ope i " of the do/ume t ,pe/ified i the IA HREF@)J ta" if the ima"e i, a lar"e ima"e the there i, a eed to li 4 multiple do/ume t, to the ,ame ima"e; there ha, to be a te/h i9ue that di5ide, the ima"e i to multiple ,e/tio , a d allo!, li 4i " of ea/h ,e/tio to a differe t do/ume t)
ICENTERJ THIS IS I%AGE %AP IBRJ II%G SRCMQE?SWALLPAPERSFrie dl* Creature,S/hi/4,)&PGQ HEIGHTM177 WI#THM277 u,emapMW/ampa,J Imap ameM/ampa,J Iarea ,hapMre/t /oord,M7;7;677;877 hrefMQa6)htmlQJ I:mapJI:CENTERJI:BO#(J IHT%LJ OPUTUT:
FRA%ES
I trodu/tio
The HT%L ta", that di5ided a bro!,er ,/ree i to t!o or more)HT%L re/o" iOable u i9ue re"io , i, the IFrame,etJ I:Frame,etJ ta",) Ea/h u i9ue re"io , i, /alled a frame)
33
The HT%L frame, i, a po!erful feature that e able u i9ue ,e/tio , that; althou"h related operate i depe de tl* of ea/h other) The IFRA%ESETJ ta" IFrame,et ro!,M =27T;27T>J IFrame,et /ol,M =27T;27T>J I:frame,etJ IFrame,et /ol,M =27T; 27T>J I:Frame,etJ I:Frame,etJ
Attribute, of Frame,et
Sir,+ #o/ume t to be loaded) %ar"i hei"ht+ Amou t of ,pa/e to be left at the top a d bottom of frame) %ar"i !idth+ Amou t of ,pa/e to left alo " the ,ide of the frame) Name+ Gi5e, the frame a u i9ue ame ,o that it /a be tar"eted b* other do/ume t
INTRO#$CTION TO &A'ASCRIPT
To ma4e a ,tati/ !eb pa"e d* ami/ i)e) ma4e it re,po d to u,erE, a/tio it i, re9uired that ,ome pro"rammi " lo"i/ mu,t be embedded I it that ma ipulate, the propert* 5alue, of !eb pa"eE, item, /alled #O% ob.e/t) &a5aS/ript, doe, thi, !or4) Creati " a d* ami/ !eb pa"e i 5ol5e, !riti " ,/ript, to /ha "e propert* ,etti ", a d to /all up pro/e,,i " method, a,,o/iated !ith #O% ob.e/t, ,urrou di " the pa"e) Ad5a ta"e, of &a5aS/ript Embedded !ithi HT%L+ &a5a,/ript /ode i, pla/ed i bet!ee HT%L /ode i )htm or )html file, ,o there i, o eed to put the /ode i ,eparate file, a d either i, the eed to ha5e a ,eparate te<t editor to !rite .a5a,/ript /ode) %o,t of the !eb authori " tool, u der,ta d, .a5a ,/ript /ode too) E") #ream!ea5er) %i imal S* ta<+ Ea,* to lear ) Yui/4 #e5elopme t+ &a5a,/ript i, ot a /ompli/ated la "ua"e a d it, pro"rammi " /o ,tru/t, are ea,* to lear ,o it ta4e, 5er* le,, time for .a5a,/ript pro"ram, to build)
35
A I terpreted La "ua"e+ &a5a,/ript i, a i terpreted la "ua"e; !hi/h re9uire, o /ompilatio ,tep,) Thi, pro5ide, a ea,* de5elopme t pro/e,,) The ,* ta< i, /ompletel* i terpreted b* the bro!,er .u,t a, it i terpret, HT%L ta",) Pro/edural Capabilitie,+ &a5a,/ript i, e9uipped !ith all the ,ta dard ba,i/ pro"rammi " /o ,tru/t, li4e /o ditio /he/4i "; loopi " a d bra /hi ") Writi " &a5aS/ript i to HT%L &a5aS/ript ,* ta< i, embedded i to a HT%L file) A bro!,er read HT%L file, a d i terpret, HT%L ta",) The bro!,er i, "i5e thi, i formatio u,i " HT%L ta", ISCRIPTJ@ I:SCRIPTJ) The ISCRIPTJ ta" mar4, the be"i i " of ,/ripti " /ode) The paired I:SCRIPTJ mar4, the a d of the , ippet of ,/ripti " /ode) The attribute, are ? La "ua"e+ Writi " the , ippet of ,/ripti " /ode) If left u defi ed et,/ape /ommu i/ator !ill a,,ume .a5a,,ript) If left u defi ed I ter et e<plorer !ill a,,ume 'B ,/ript S* ta< ISCRIPT LANG$AGEM =&a5aS/ript>J &a5aS/ript /ode , ippet !ritte here I:SCRIPTJ AlertF G method It i, a method of the !i do! ob.e/t) It i, emplo*ed to di,pla*ed pop+up bo<e, !ith ,ome te<t a d a butto labeled =O0>) $,a"e of the alertF G method i, ,imilar to the !rite method F G of the !i do! ob.e/t) The te<t pla/ed i ,ide the pare the,i, i, di,pla*ed the pop+up) Wi do!)alertF=I am a alert bo<>GZ Si /e itE, ot e/e,,ar* the !i do! ob.e/t !e /a lea5e it out form the /ode) Thu, follo!i " /ode !ill fu /tio efuall* !ell a, o e abo5e) alertF=I am a alert bo<>GZ Creati " 'ariable,
36
I &a5aS/ript; 5ariable, /a be /reated that /a hold a * t*pe of data) I order to u,e a5ariable; it i, "ood pro"rammi " ,t*le to de/lare it)
37
&a5aS/ript Arra* A arra* mu,t be de/lared before it i, u,ed) A arra* /a be de/lared u,i " a * o e of the follo!i " te/h i9ue,) arra*Name M e! Arra* Fle "thG arra*Name M e! Arra* F G Operator, a d E<pre,,io i .a5aS/ript A operator, i, u,ed to tra ,form o e or more 5alue, i to a ,i "le re,ulta t 5alue) Arithmeti/ Operator, Arithmeti/ operator, are the mo,t familiar operator, be/au,e the* are u,ed e5er* da* to ,ol5e /ommo mathemati/al /al/ulatio ,) The arithmeti/ operator, that &a5aS/ript ,upport, are? [ + X : T [[ ++ Lo"i/al Operator, Lo"i/al operator, are u,ed to perform Boolea opera d, a d; or; ot) The lo"i/al operator, ,upported b* &a5aS/ript are? \\ ] ] K Compari,o Operator, Compari,o operator, are u,ed to /ompare t!o 5alue,) The /ompari,o operator, ,upported b* &a5aS/ript are? MM MMM KM KMM I IM J JM Stri " Operator, Stri " operator, are tho,e operator, that are u,ed to perform operatio o ,tri ",) Curre tl*; &a5aS/ript ,upport, o l* the ,tri " /o /ate atio F[G operator) Thi, operator i, u,ed to .oi t!o ,tri ",; e)"); =ab> [ =/d> proud,e =ab/d>) #elete Operator The delete operator i, u,ed to delete a propert* of a ob.e/t or a eleme t at a arra* i de<) E<ample delete m*arra* U2V
38
#elete the ,i<th eleme t of Arra*) &a5aS/ript IF+ELSE Stateme t Ea/h /o ditio ha, t!o path, from !hi/h !e /hoo,e o e) For e<ample; =If itE, rai i "; IEll ,ta* at home el,e I>ll "o out for a ,troll)> &u,t li4e the /o ditio , of e5er*da* life; the /o ditio al if ,tateme t i &a5aS/ript ha, a el,e /lau,e) It allo!, u, to ta4e the alter ate path !he the /o ditio i if i, fal,e) If F !eather MM =rai i "> G ^ alter F= I _ll ,ta* at home>GZ ` el,e ^ alert F= IE ll "o out for a,troll>GZ The follo!i " /ode /he/4, if a umber i, e5e or odd a d di,pla*, a appropriate bo<) 'ar M =6A>Z
If F T6G ^ alert F=Number i, odd>GZ ` el,e ^ alert F=Number i, e5e >GZ ` &a5aS/ript H El,e If
39
WeE5e alread* lear t that /o ditio , /a ta4e o e of the po,,ible t!o path,) That i,; !he /o ditio i, _trueE the if ,tateme t blo/4 i, e<e/uted !hile the ,tateme t blo/4 i el,e i, e<e/uted !he the /o ditio i, _fal,eE) Ho!e5er; a, i life; thi ", are rarel* bla/4 or !hite@ there are al!a*, ,hade, of "ra*) If F umber J 7G ^ alertF=Number i, a po,iti5e i te"er>G ` el,e if F umber I 7G ^ alertF=Number i, a e"ati5e i te"er>GZ ` El,e ^ alert F=Number i, 7>GZ ` Ne,ted if Some people fi d Boolea /o ditio , 5er* ,imple; other people do Et) I fa/t; it i, po,,ible to a5oid u,i " them alto"ether) (ou /a repla/e OR !ith ,e5eral if ,tateme t,; o e after the other; po,,ibl* !ith el,e u,ed a, !ell) (ou !ill ha5e to repeat the /ode) (ou /a repla/e AN# !ith e,ted if ,tateme t,; that i,; O e if ,tateme t i ,ide a other o e) Immediate if A /o ditio e<pre,,io /a e5aluate to either True or Fal,e ba,ed o the e5aluatio of the /o ditio ) The ,tru/ture of a /o ditio al e<pre,,io i,? S* ta< F/o ditio G a 5alue8 ? 5alue6 E<ample
40
'ar da* M =Su da*> Fda* MM =Su da*>G a =Holida*K> ? =Not Su da*K> Thi, e<pre,,io !ill, e5aluate to =Holida*K> !here da* hold, Su da*K> FCo ditio TR$EG
=Not Su da*K> if da* hold, a * other ,tri " FCo ditio FALSEG For Loop, The for loop i, the mo,t ba,i/ t*pe of loop re,emble, a loop i pro"rammi " la "ua"e,; i /ludi " ANSIC) S* ta< For Fe<pre,,io 8Z /o ditio Z e<pre,,io 6 ^ &a5aS/ript /omma d, ` !here E<ample For F5ar ^ #o/ume t ) !rite F umGZ ` While Loop The !hile loop pro5ide, a ,imilar fu /tio alit*) The ba,i/ ,tru/ture of a !hile loop i,? S* ta< While F/oditio G ^ &a5aS/ript /omma d,
41
mo,t other
` E<ample The follo!i " blo/4 pri t, umber, from 8 to 87 o the ,/ree 'ar um M 8Z
Fu /tio , i &a5aS/ript
Fu /tio , are blo/4 &a5aS/ript /ode that perform a ,pe/ifi/ ta,4 a d ofte retur a 5alue) A &a5aS/ript fu /tio ma* ta4e Oero or more parameter,) Parameter, are a ,ta dard te/h i9ue 5ia !hi/h /o trol /a be pa,,ed to a fu /tio ) Bilt+i fu /tio , &a5aS/ript pro5ide ,e5eral built+i fu /tio , that /a be u,ed to perform e<pli/it T*pe /o 5er,io ,) Some of them are e5alF G; par,el tF G a d par,efloat F G) The e5ilF G fu /tio /a be u,ed to /o 5ert a ,tri " e<pre,,io to a umeri/ 'alue) E<ample 'ar "ra d-Total M e5el F=87X67[C>GZ Re,ult, i the 5alue67C bei " a,,i" ed to the 5ariable "ra d-Total)
A blo/4 of &a5aS/ript /ode that defi e, !hat the fu /tio doe S* ta< Fu /tio Fu /tio - ame Fparameter8; parameter6; @G ^ Blo/4 of &a5aS/ript /ode
` Re/ur,i5e Fu /tio
Re/ur,io refer, to a ,ituatio !herei fu /tio /all, them) I other !ord,; there i, /all to a ,pe/ifi/ fu /tio from !ithi the ,ame fu /tio )
E<ample Fu /tio Fa/torial ^ If F umber J8G ^ retur ` el,e ^ retur ` ` Pla/i " Te<t i a Bro!,er Ob.e/t H ame )%ethod H Name do/ume t )!rite F=Te,t>GZ #ialo" Bo<e,
43
umberZ
&a5aS/ript pro5ide the abilit* to pi/4up u,er i put or di,pla* ,mall amou t, of te<t to the u,er b* u,i " dialo" bo<) The,e dialo" bo<e, appear a, ,eparate !i do!, a d their /o te t depe d, o the i formatio pro5ide b* the u,er) Alert #ialo" Bo< The ,imple,t !a* to dire/t ,mall amou t, of te<tual output to a bro!,erE, Wi do! i, to u,e a alert dialo" bo<) The alert dialo" bo< di,pla* the ,tri " pa,,ed to alertF G method; a, !ell a, a O0 butto ) The &a5aS/ript a d the HT%L pro"ram i !hi/h thi, /ode , ippet i, held; !ill ot /o ti ue pro/e,,i " u til the O0 butto i, /li/4ed)
OUTPUT:
44
Prompt #ialo" Bo< The alert dialo" bo< ,impl* di,pla* i formatio i a bro!,er a d doe, ot allo! a * i tera/tio ) The additio of the O0 butto pro5ide, ,ome 5er* mi imal /o trol o5er from e5e t,; i)e); pro"ram e<e/utio halt, /ompletel* u it ,ome u,er a/tio ta4e, pla/e)
OUTPUT:
Co firm #ialo" Bo< &a5aS/ript pro5ide, a third t*pe of a dialo" bo<; /alled the /o firm dialo" bo<) A, the ame ,u""e,t,; the dialo" bo< ,er5e, a, a te/h i9ue, for /o fifmi " u,er a/tio )
FOR% $SE# B( A WEB SITE A HT%L form pro5ide, data "atheri " fu /tio alit* to a !eb pa"e) Thi, i, 5er* u,eful if the !eb ,ite i, u,ed to ad5erti,e a d ,ell produ/t,) HT%L form, /a pro5ide a full ra "e of G$I /o trol,) The data ,ubmitted /a be pro/e,,ed at he !eb ,er5er b* GI pro"ram,; ,er5er ,ide &a5aS/ript; &a5a Ser5let,; et/) Form Ob.e/t, Butto H a G$I pu,hbutto /o trol) %ethod, are /li/4 F G; blur F G; a d fo/u, F G) Attribute, Name; 5alue Che/4bo< H A G$I /he/4 bo< /o trol) %ethod, are /li/4 F G;blurF G; ;a d fo/u,F G) FILE$PLOA#+thi, i, /reated !ith the INP$T t*peM>file>)method are blurF G;;a d fo/u,F G; HI##EN+ a ob.e/t that repre,e t a hidde form field a d i, u,ed for /lie t:,er5er /ommu i/atio ,) PASSWOR#+ a te<t field u,ed to ,e d ,e ,iti5e data to the ,er5er) %ethod are blurF G;fo/u,F G;a d ,ele/tF G;) RA#IO+ a G$I radio butto /o trol) %ethod, are /li/4F G;blurFG; a d fo/u,F G) RESET+a butto ob.e/t u,ed to re,et a form ba/4 to default 5alue,) %ethod, are /li/4F G;blurF G; a d fo/u,F G) SELECT+ a "ui ,ele/tio li,t thi, i, ba,i/all* a drop do! li,t) %ethod are blurF G; a d fo/u,F G) S$B%IT+ a ,ubmit butto ob.e/t) /li/4 F G;blurF G; ;a d fo/u,F G) TEPT+ a G$I te<t field ob.e/t) %ethod are blurF G; fo/u,F G; a d ,ele/tF G; TEPTAREA+ a G$I te<t area field ob.e/t) %ethod are blurF G;fo/u,FG;a d ,ele/tF G)
48
'AL$E+ the te<t that i, e tered a d appear, i the te<t area field it i, u,ed to ,e d to the ,er5er !he the form i, ,ubmitted)
PINNAIINP$T T(PEMCHEC0BOPJIBRJ B$RGERIINP$T T(PEMCHEC0BOPJIBRJ NOO#LESIINP$T T(PEMCHEC0BOPJIBRJ HOT#OGIINP$T T(PEMCHEC0BOPJIBRJ Ii put t*peMQ,ubmitQ 5alueMQ,ubmitQJ Ii put t*peMQre,etQ 5alueMQre,etQJIbrJ I:BJ I:FONTJ I:FOR%JI:hAJ I:HT%LJ OUTPUT:
50
COO0IES
Coo4ie, !ill i trodu/e *ou to !hat /oo4ie, are a d ho! bro!,er, u,e the,e /oo4ie, for mai tai i " ,tate for de5elopi " /riti/al i tera/ti5e appli/atio ,) (ou !ill lear about ,et+/oo4ie, a d /oo4ie field,; !hi/h are u,ed to tra ,fer i formatio bet!ee the /lie t a d the ,er5er)
Setti " a /oo4ie S* ta< Set+/oo4ie? NA%EM5alueZ #O%AINMdomai Z SEC$RE EPPIRESMdataZ PATHMpathZ that mu,t be
The NA%EM5alue i, the o l* re9uired pie/e of i formatio i /lude i the ,et+/oo4ie field) NA%EM 5alue; ,pe/ifie, the ame of /oo4ie) EPPIRESMdate; Spe/ifie, the e<pir* data of the /oo4ie)
PATHMpath; Spe/ifie, the path portio of the $RL, for !hi/h the /oo4ie i, 5alid)
51
#O%ANMdomai ; Spe/ifie, the domai portio of the $RL, for !hi/h the /oo4ie i, 5alid) SEC$REMSpe/ifie, that the /oo4ie ,hould o l* be tra ,mitted o5er a ,e/ure li 4)
IhtmlJ IheadJ ItitleJ .a5eI:titleJ I,/ript la "ua"eMQ.a5a,/riptQJ 5ar aMpromptFQENTER THE N$%BERQ;QN$%BERQG ifFa:6MM7G ^ do/ume t)!riteFQI/e terJIh8JN$%BER IS E'ENI:H8JICENTERJQG ` el,e ^do/ume t)!riteFQI/e terJIh8JN$%BER IS O##I:H8JICENTERJQG `
52
fu /tio helloFG ^ alertFQHELLO HOW R $aaQG ` I:,/riptJ I:headJ Ibod*J IINP$T T(PEMQB$TTONQ 'AL$EMQCLIC0Q ONCLIC0MQhelloFGQJ I:bod*J I:htmlJ
OUTPUT:
54