Professional Documents
Culture Documents
Createafor
m havi
ngnumberofel
ement
s.Wri
teajava
scri
ptcodetocountt
henumberofel
ement
sinaform.
<ht
ml>
<head>
<t
it
le>COUNTOFNUMBEROFELEMENTSI
NAFORM</
ti
tl
e>
<scr
iptt
ype="
text
/j
avascr
ipt
">
f
unct
ioncount
Element
s()
al
ert
("
Thenumberofel
ement
sinf
orm1ar
e:"
+document
.f
orm1.
lengt
h);
</
scr
ipt
>
</
head>
<bodybgcol
or="
li
ght
grey
">
<f
orm name="
for
m1"
>
<pr
e>
Fi
rstname:
<inputt
ype="
text
"name="
fname"v
alue="
"/><br
/>
Lastname:
<inputt
ype="
text
"name="
lname"v
alue="
"/><br
/><br
/>
<b>Gender
</b>
Mal
e<I
NPUTTYPE="
radi
o"NAME="
rad"VALUE="
radi
o_but
ton1"/
>
Femal
e<I
NPUTTYPE="
radi
o"NAME="
rad"VALUE="
radi
o+but
ton2"/
><br
/>
<b>Educat
ion</
b>
UnderGr
aduat
e<I
NPUTTYPE="
checkbox"NAME="
check1"/
>
Gr
aduat
e<I
NPUTTYPE="
checkbox"NAME="
check2"Val
ue="
Check2"/
>
PostGr
aduat
e<I
NPUTTYPE="
checkbox"NAME="
check3"Val
ue="
Check3"
/>
<i
nputt
ype="
submi
t"v
alue="
Submi
t"onCl
i
ck="
count
Element
s()
"/>
</
for
m>
</
body
>
</
html
>
2.CreateaHTMLf or
mt hathasnumberoft ext
boxes.Whenthe
formr unsintheBrowserfil
li
nthet extboxeswit
hdata.Writ
ea
Jav ascri
ptcodethatver
ifi
esthatalltext
boxeshasbeenf i
l
led.i
F
at extboxeshasbeenleftempty,popupanal er
tindi
cati
ngwhich
textboxhasbeenl ef
tempt y.
<ht
ml>
<head>
<t
it
le>Cont
actFor
m</
ti
tl
e>
<scr
iptt
ype="
text
/j
avascr
ipt
">
f
unct
ionv
ali
dat
e()
i
f(
document
.my
For
m.Name.
val
ue=="
")
al
ert
("
Pleasepr
ovi
dey
ourName"
);
document
.my
For
m.Name.
focus(
);
r
etur
nfal
se;
i
f(
document
.my
For
m.Emai
l
.val
ue=="
")
al
ert
("
Pleasepr
ovi
dey
ourEmai
lID"
);
document
.my
For
m.Emai
l
.focus(
);
r
etur
nfal
se;
i
f(
document
.my
For
m.Phone.
val
ue=="
")
al
ert
("
Pleasepr
ovi
dey
ourPhoneNumber
");
document
.my
for
m.Phone.
focus(
);
r
etur
nfal
se;
r
etur
ntr
ue;
</
scr
ipt
>
</
head>
<body
>
<cent
er><h2>CONTACTFORM</
h2>
<f
orm name="
myFor
m"onsubmi
t="
ret
urn(
val
i
dat
e()
)";
>
<t
abl
ecel
l
spaci
ng="
2"cel
l
paddi
ng="
2"bor
der="
1">
<t
r>
<t
d>Name</
td>
<t
d><i
nputt
ype="
text
"name="
Name"/
></
td>
</
tr>
<t
r>
<t
d>Emai
lID</
td>
<t
d><i
nputt
ype="
text
"name="
Emai
l
"/></
td>
</
tr>
<t
r>
<t
d>Phone</
td>
<t
d><i
nputt
ype="
text
"name="
Phone"/
></
td>
</
tr>
<t
r>
<t
dcol
span="
2"al
i
gn="
cent
er"
><i
nputt
ype="
submi
t"v
alue="
Submi
t"/
>
</
td>
</
tr>
</
tabl
e>
</
for
m>
</
cent
er>
</
body
>
</
html
>
3.Devel
opaHTMLFor m,whichacceptsany
Mathematical
expressi
on.Wri
teaJav aScr
iptcodet
o
eval
uatetheexpr
essionanddispl
aytheresult
.
<ht
ml>
<head>
<t
it
le>Sol
uti
onofMat
hemat
ical
Expr
essi
on</
ti
tl
e>
<scr
iptt
ype="
text
/j
avascr
ipt
">
f
unct
ioncal
c()
document.
fr
mExp.r
esul
t.
val
ue=
eval
(document.
fr
mExp.
expr.
val
ue)
</
scr
ipt
>
</
head>
<body
>
<f
orm name="
frmExp"
>
Ent
eramathemat
ical
expressi
oninthetextbox,
Cli
ckon
Cal
cul
atebut
tont
odispl
aytheresul
t<br
></br>
<tabl
ecell
paddi
ng="4"cel
l
spaci
ng="
0"hei
ght
=100wi
dth=200
bgcolor
="l
i
ghtgr
ey">
<t
r>
<t
d><i
nputt
ype="
text
"si
ze="
20"name="
expr
"></
td>
<t
d><inputt
ype="butt
on"name="
But
ton1"v
alue="
Cal
cul
ate"
oncl
i
ck="cal
c()
"></td>
</
tr>
<t
r>
<td><b>Resul
t:</
b><i
nputt
ype="
text
"si
ze="
20"
name=" r
esult
"></t
d>
<t
d><i
nputt
ype="
reset
"name="
reset
"val
ue="
Reset
"></
td>
</
tr>
</
tabl
e>
<p>Cl
i
ckonResetbut
tont
oent
eranot
hernewexpr
essi
on.
</p>
</
for
m>
</
body
>
</
body
>
</
html
>
4.
Dynami
cst
acki
ng
<!
DOCTYPEht
ml>
<!
--st
ack.
html
Adocumentf
ordy
nami
cst
acki
ngofi
mages
-
->
<head>
<t
it
le>DYNAMI
CSTACKI
NGOFI
MAGES</
ti
tl
e>
<scr
iptt
ype="
text
/j
avascr
ipt
">
v
art
op="
i1"
;
f
unct
iont
oTop(
newTop)
domTop=document
.get
Element
ByI
d(t
op)
.st
yle;
domNew=document
.get
Element
ByI
d(newTop)
.st
yle;
domTop.
zIndex="
0";
domNew.
zIndex="
10"
;
t
op=newTop;
</
scr
ipt
>
<st
ylet
ype="
text
/css"
>
.
img1{
posi
ti
on:
absol
ute;
top:
0;l
eft
:0;
z-i
ndex:
0;}
.
img2{
posi
ti
on:
absol
ute;
top:
40px;
lef
t:80px;
z-i
ndex:
0;}
.
img3{
posi
ti
on:
absol
ute;
top:
50px;
lef
t:100px;
z-i
ndex:
0;}
</
sty
le>
</
head>
<body
>
<p><i
mgcl ass="i
mgg1"i
d="
i1"sr
c="
sneha.
jpg"
oncli
ck="
toTop(
'i
1'
)"/
>
<i
mgcl
ass="
img2"i
d="
i2"sr
c="
sneha.
jpg"oncl
i
ck="
toTop(
'i
2'
)"
/>
<i
mgcl
ass="
img3"i
d="
i3"sr
c="
sneha.
jpg"oncl
i
ck="
toTop(
'i
3'
)"
/>
</
p>
</
body
>
</
html
>
5.
Wri
tr
eaj
avascr
iptcodet
ofi
ndt
hesum ofNnat
ural
number
s.
(
Useuser
-def
inedf
unct
ion)
<ht
ml>
<head>
<t
it
le>SUM OFNNATURALNUMBERS</
ti
tl
e>
<scr
iptt
ype="
text
/j
avascr
ipt
">
v
arnum,
n,
s=0;
num=wi
ndow.
prompt
("
Ent
eranumber
",
"0"
);
n=par
seI
nt(
num)
;
i
f(
n<=0)
al
ert
("
Ent
eraposi
ti
venumber
");
}
document
.wr
it
e("
<h1><cent
er>Sum of"+n+"nat
ural
number
sis:
")
;
f
indsum(
n);
document
.wr
it
e(s+"
</cent
er></
h1>"
);
f
unct
ionf
indsum(
n)
f
or(v
ari
=0;
i<=n;
i++)
s=s+i
;
</
scr
ipt
>
</
head>
<bodybgcol
or="
powder
blue"
>
</
body
>
</
html
>
6.
Wri
teaj
avascr
iptcodet
ofi
ndf
act
ori
alofanumber
.
<!
DOCTYPEht
ml>
<ht
ml>
<head>
<t
it
le>Recur
siv
efact
ori
alf
unct
ion</
ti
tl
e>
<scr
iptt
ype="
text
/j
avascr
ipt
">
v
arnumber
,n;
num =wi
ndow.
prompt
("
Ent
ert
henumbert
ofi
ndf
act
ori
al"
,"
0")
;
n=par
seI
nt(
num)
;
document
.wr
it
e("
<h1><cent
er>Fact
ori
alof"+n+"i
s")
;
f
or(v
ari
=0;
i<=n;
i++)
v
arf
=fact
(n)
;
document
.wr
it
e("
<i>"
+f+"
</i
></
cent
er></
h1>"
);
f
unct
ionf
act
(n)
i
f(
n==1)
r
etur
n1;
el
se
r
etur
nn*
fact
(n-
1);
</
scr
ipt
>
</
head>
<bodybgcol
or="
red"
></
body
>
</
html
>
7.Wri
teaJavaScr
iptcodeblockusi
ngarraysandgener
atet
he
cur
rentdat
einwords,t
hisshouldi
ncludetheday,
monthandyear
.
<ht
ml>
<head>
<t
it
le>Cur
rentDat
e</
ti
tl
e>
<scr
iptt
ype="
text
/j
avascr
ipt
">
v
ard_names=newArray
("Sunday"
,"Monday"
,"Tuesday
",
"
Wednesday
","
Thur
sday"
,"Fri
day"
,"Sat
urday
");
v
arm_names=newAr ray
("January
","Febr
uary"
,"March",
"Apr
il
",
"
May",
"June"
,"Jul
y",
"August",
"Septemeber",
"October"
,
"
Novemeber"
,"Decemeber"
);
v
ard=newDat
e()
;
v
arcur
r_day
=d.
get
Day
();
v
arcur
r_dat
e=d.
get
Dat
e()
;
v
arsup="
";
i
f(
cur
r_dat
e==1|
|cur
r_dat
e==21|
|cur
r_dat
e==31)
sup="
st"
;
el
sei
f(cur
r_dat
e==2|
|cur
r_dat
e==22)
sup="
nd"
;
}
el
sei
f(
cur
r_dat
e==3|
|cur
r_dat
e==23)
sup="
rd"
;
el
se
sup="
th"
;
v
arcur
r_mont
h=d.
get
Mont
h()
;
v
arcur
r_y
ear=d.
get
Ful
l
Year
();
document.
wr i
te("
<h1><center
>"+d_ names[cur
r_day]+""+
curr
_dat
e+" <SUP>"+sup+" </SUP>"+m_ names[curr
_month]+"
"+curr_
year+" </cent
er></
h1>");
</
scr
ipt
>
</
head>
<bodybgcol
or="
cyan"
>
</
body
>
</
html
>
8.
Creat
eaf ormforSt
udenti
nfor
mation.Wr
it
eJav
ascr
iptcodet
o
fi
ndTotal
,
Av er
age,
Resul
tandGrade.
<ht
ml>
<head>
<t
it
ele>Decl
arat
ionofr
esul
tsofst
udent
s</
ti
tl
e>
<scr
ipt
>
f
unct
ionf
indResul
t(
)
v
arr
esul
t="
";
v
argr
ade="
";
v
arst
udname=document
.f
rmSt
udent
.sname.
val
ue;
v
arm1=par
seI
nt(
document
.f
rmSt
udent
.mar
k1.
val
ue)
;
v
arm2=par
seI
nt(
document
.f
rmSt
udent
.mar
k2.
val
ue)
;
v
arm3=par
seI
nt(
document
.f
rmSt
udent
.mar
k3.
val
ue)
;
v
arm4=par
seI
nt(
document
.f
rmSt
udent
.mar
k4.
val
ue)
;
v
arm5=par
seI
nt(
document
.f
rmSt
udent
.mar
k5.
val
ue)
;
v
arm6=par
seI
nt(
document
.f
rmSt
udent
.mar
k6.
val
ue)
;
v
art
otal
=(m1+m2+m3+m4+m5+m6)
;
v
arav
g=Mat
h.r
ound(
tot
al/
6);
i
f(
m1<40|
|
m2<40|
|
m3<40|
|
m4<40|
|
m5<40|
|
m6<40)
r
esul
t="
Fai
l
";
el
se
v
armm=av
g;
i
f(
mm>=80)
gr
ade="
A";
r
esul
t="
Dist
inct
ion"
;
el
sei
f(
mm>=60)
gr
ade="
B"
r
esul
t="
Fir
stcl
ass"
;
el
sei
f(
mm>=50)
gr
ade="
C";
r
esul
t="
Secondcl
ass"
;
el
sei
f(
mm>=40)
gr
ade="
D";
r
esul
t="
Pass"
;
el
sei
f(
mm<50)
{
gr
ade="
F";
r
esul
t="
Fai
l
";
document.wri
te("
<br
/><pr
e>-
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-
--
--
--
--
--
--
--
--
--
<br/>"
);
document
.wr
it
e("
<br
/><h1>B.
Sc.VSemest
er-
RESULTSHEET </
h1>"
);
document.wri
te(
"<br
/>-
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-<br
/>")
;
document
.wr
it
e("
<br
/>St
udentName :
: <b>"
+st
udname+"
</b>"
);
document
.wr
it
e("
<br
/>Tot
alMar
ks :
: <b>"
+tot
al+"
/600"
+"</
b>"
);
document
.wr
it
e("
<br
/>Av
erageMar
ks :
: <b>"
+av
g+"
</b>"
);
document
.wr
it
e("
<br
/>Resul
t :
: <b>"
+resul
t+"
</b>"
);
document
.wr
it
e("
<br
/>Gr
ade :
: <b>"
+gr
ade+"
</b>"
);
document.wri
te(
"<br/>-
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
-</
pre><br/
>");
</
scr
ipt
>
</
head>
<bodybgcol
or="
li
ght
grey
">
<f
orm name="
frmSt
udent
">
<cent
er><b><h1>STUDENTI
NFORMATI
ON</
h1></
b></
cent
er><br
/><br
/>
<h2>Pl
easef
il
li
ndet
ail
s:</
h2>
<pr
e>
STUDENTNAME : <i
nputt
ype="
text
"name="
sname"
><br
>
PHYSI
CSV : <i
nputt
ype="
text
"name="
mar
k1"
><br
/>
PHYSI
CSVI : <i
nputt
ype="
text
"name="
mar
k2"
><br
/>
MATHEMATI
CSV : <i
nputt
ype="
text
"name="
mar
k3"
><br
/>
MATHEMATI
CSVI : <i
nputt
ype="
text
"name="
mar
k4"
><br
/>
COMPUTERSCI
ENCEV : <i
nputt
ype="
text
"name="
mar
k5"
><br
/>
COMPUTERSCI
ENCE : <i
nputt
ype="
text
"name="
mar
k6"
><br
/>
</
pre>
<i
nputt
ype="
but
ton"v
alue="
Submi
t"oncl
i
ck="
fi
ndResul
t(
);
">
</
for
m>
</
body
>
</
html
>
9.Cr
eat
eafor
mf orEmpl
oyeeinf
ormati
on.Wri
tej
avascr
iptcode
tofi
ndDA,
HRA,PF,
TAX,
GrossPay,
Deducti
onandNetpay.
<ht
ml>
<head>
<t
it
le>EMPLOYEEI
NFORMATI
ON</
ti
tl
e>
<scr
ipt
>
f
unct
ionf
indSal
ary
()
{
v
arempname=document
.f
rmEmp.
ename.
val
ue;
v
aredept
=document
.f
rmEmp.
dept
.val
ue;
v
arbasi
cpay
=par
seI
nt(
document
.f
rmEmp.
basi
c.v
alue)
;
v
arda,
hra,
tax,
pf,
grosspay
,deduct
ions,
net
pay
;
da=basi
cpay
*0.
5;
hr
a=basi
cpay
*0.
15;
gr
osspay
=basi
cpay
+da+hr
a;
pf
=gr
osspay
*0.
12;
t
ax=gr
osspay
*0.
1;
deduct
ions=pf
+tax;
net
pay
=gr
osspay
-deduct
ions;
document
.wr
it
e("
<h1>EMPLOYEESALARYDETAI
LS</
h1><br
/></
br>"
);
document
.wr
it
eln(
"Empl
oyeeName :
<b>"
+empname+"
</b>></
br>"
);
document
.wr
it
eln(
"Basi
cpay :
<b>"
+basi
cpay
+"</
b></
br>"
);
document
.wr
it
eln(
"Dear
nessAl
l
owance :
<b>"
+da+"
</b></
br>"
);
document
.wr
it
eln(
"HouseRentAl
l
owances:
<b>"
+hr
a+"
</b></
br>"
);
document
.wr
it
eln(
"Gr
ossSal
ary :
<b>"
+gr
osspay
+"</
b></
br>"
);
document
.wr
it
eln(
"Deduct
ions :
<b>"
+deduct
ions+"
</b></
br>"
);
document
.wr
it
eln(
"NetSal
ary :
<b>"
+net
pay
+"</
b>"
);
</
scr
ipt
>
</
head>
<bodybgcol
or="
li
ght
grey
">
<f
orm name="
frmEmp"
>
<cent
er><b><h1>EMPLOYEESALARY
DETAILS</h1></b></
cent
er><br
/><br
/>
<h2>Ent
erEmpl
oyeeName,
Depar
tmentandBasi
cPay
</h2>
<pr
e>
<f
ontsi
ze="
4">
<cent
er><h1>EMPLOYEESALARYDETAI
LS</
h1></
cent
er>
EMPLOYEENAME <i
nputt
ype="
text
"name="
ename"
><br
/>
DEPARTMENT <i
nputt
ype="
text
"name="
dept
"><br
/>
BASI
CPAY <i
nputt
ype="
text
"name="
basi
c"><br
/><br
/>
</
font
>
</
pre>
<i
nputt
ype="
but
ton"v
alue="
Cal
cul
ateNetSal
ary
"oncl
i
ck="
fi
ndSal
ary
();
">
</
body
>
</
html
>
10.
Creat
eaf or
m consi
stsofat
womul
ti
plechoi
cel
i
stsandone
si
ngl
echoiceli
st.
1.
)Thef
ir
stmul
ti
plechoi
cel
i
st,
displ
ayst
hemaj
ordi
shesav
ail
abl
e.
2.
)Thesecondmul
ti
plechoi
cel
i
st,
displ
ayst
hest
art
ersav
ail
abl
e.
3.
)Thesi
ngl
echoi
cel
i
st,
displ
ayst
hesof
tdr
inksav
ail
abl
e.
<ht
ml>
<head>
<t
it
le>MenuDr
ivenPr
ogr
am</
ti
tl
e>
<scr
ipt
>
f
unct
ionf
indCost
()
v
arst
art
er=document
.get
Element
ByI
d("
star
ter
");
v
armai
n=document
.get
Element
ByI
d("
mai
n")
;
v
arsof
t=document
.get
Element
ByI
d("
sof
t")
;
v
arsel
ect
edi
tem="
It
em\
t\t
\t\
tPr
ice\
n--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
\n"
;
v
art
otal
=0;
f
or(
vari
=0;
i
<st
art
er.
opt
ions.
lengt
h;i
++)
v
archoi
ce=st
art
er.
opt
ions[
i]
;
i
f(
choi
ce.
sel
ect
ed==t
rue)
v
arpr
ice=par
seI
nt(
choi
ce.
val
ue)
;
t
otal
=tot
al+pr
ice;
sel
ect
edi
tem=sel
ect
edi
tem+choi
ce.
text
+"\
t\t
\t"
+pr
ice+"
\n"
;
}
}
f
or(
vari
=0;
i
<mai
n.opt
ions.
lengt
h;i
++)
v
archoi
ce=mai
n.opt
ions[
i]
;
i
f(
choi
ce.
sel
ect
ed==t
rue)
v
arpr
ice=par
seI
nt(
choi
ce.
val
ue)
;
t
otal
=tot
al+pr
ice;
sel
ect
edi
tem=sel
ect
edi
tem+choi
ce.
text
+"\
t\t
\t"
+pr
ice+"
\n"
;
f
or(
vari
=0;
i
<sof
t.
opt
ions.
lengt
h;i
++)
v
archoi
ce=sof
t.
opt
ions[
i]
;
i
f(
choi
ce.
sel
ect
ed==t
rue)
v
arpr
ice=par
seI
nt(
choi
ce.
val
ue)
;
t
otal
=tot
al+pr
ice;
sel
ect
edi
tem=sel
ect
edi
tem+choi
ce.
text
+"\
t\t
\t\
t"+pr
ice+"
\n"
;
sel
ect
edi
tem=sel
ect
edi
tem+"
\n\
n\nTot
alCost
\t\
t\t
"+t
otal
;
document
.get
Element
ByI
d("
displ
ay"
).
val
ue=sel
ect
edi
tem;
</
scr
ipt
>
</
head>
<bodybgcol
or="
grey
">
<br
/><br
/><br
/><br
/>
<f
orm name="
menuf
orm"
>
<t
abl
ebor
der
="10"wi
dth="
550"al
i
gn="
cent
er"bgcol
or="
orange"
>
<t
r>
<t
hcol
span="
3"al
i
gn="
cent
er"
>
<h2>Rest
aur
antMenuDet
ail
s</
h2>
</
th>
</
tr>
<t
r>
<t
d>St
art
ers</
td>
<t
d>Mai
nCour
se</
td>
<t
d>Sof
tDr
inks</
td>
</
tr>
<t
r>
<t
d>
<sel
ecti
d="
star
ter
"si
ze="
4"mul
ti
ple="
mul
ti
ple"
>
<opt
ionv
alue="
85"
>Gobi
Manchur
ian</
opt
ion>
<opt
ionv
alue="
100"
>Cor
nManchur
ian</
opt
ion>
<opt
ionv
alue="
50"
>Masal
aPapad</
opt
ion>
<opt
ionv
alue="
65"
>Tomat
oSoup</
opt
ion>
</
sel
ect
>
</
td>
<t
d>
<sel
ecti
d="
mai
n"si
ze="
4"mul
ti
ple="
mul
ti
ple"
>
<opt
ionv
alue="
100"
>Veg.Pul
ao</
opt
ion>
<opt
ionv
alue="
150"
>Jeer
aRi
ce</
opt
ion>
<opt
ionv
alue="
120"
>Cur
ry&Rot
i</
opt
ion>
<opt
ionv
alue="
160"
>Veg.Bi
ri
yani
</opt
ion>
</
sel
ect
>
</
td>
<t
d>
<sel
ecti
d="
sof
t"si
ze="
4"mul
ti
ple="
mul
ti
ple"
>
<opt
ionv
alue="
35"
>Maaza</
opt
ion>
<opt
ionv
alue="
25"
>Pepsi
</opt
ion>
<opt
ionv
alue="
30"
>Fant
a</
opt
ion>
<opt
ionv
alue="
25"
>Soda</
opt
ion>
</
sel
ect
>
</
td>
</
tr>
<t
r>
<t
dcol
span="
3"al
i
gn="
cent
er"
>
<t
ext
areai
d="
displ
ay"r
ows="
10"col
s="
70"
>
</
text
area>
</
td>
</
tr>
<t
r>
<t
dcol
span="
3"al
i
gn="
cent
er"
>
<i
nputt
ype="
but
ton"v
alue="
FindTot
alCost
"oncl
i
ck="
fi
ndCost
();
"/
>
<i
nputt
ype="
reset
"val
ue="
Clearal
l
"/>
</
tr>
</
tabl
e>
</
for
m>
</
body
>
</
html
>