Javascript

JavaScript  - Part 2 Adding to a Web Page

<html>
<head>
<title>Javascript Project</title>
<script>
alert('Hello');

</script>
</head>
<body>
</body>
</html>

JavaScript  - Part 3 Fist Script

<html>
<head>
<title>Javascript Project</title>
<script>
//document.write() Simple Hello World Script
document.write('Hello World');

</script>
</head>
<body>
</body>
</html>

JavaScript  - Part 4 External File Support 

External File Support (javascriptExternalFile.js) no use of script Tag

<html>
<head>
<title>Javascript Project</title>
<script src='javascriptExternalFile.js'>
</script>

</head>
<body>
</body>
</html>

JavaScript  - Part 5 Data Types


<html>
<head>
<title>Javascript Project</title>
<script >
name= 'Devika';
document.write(name);
document.write(3+4+5);
</script>


</head>
<body>
</body>
</html>

JavaScript  - Part 6 Variables



<html>
<head>
<title>Javascript Project</title>
<script >
val_1= 2;
val_2= 3;
val_7= Hello;
val_9= World;
ans= val_1+val_2;
document.write(val_1+val_2);
document.write(val_7+' <br>'+val_9);
document.write(ans);
name= 'Devika';
document.write(name);
document.write(3+4+5);
</script>


</head>
<body>
</body>
</html>

JavaScript  - Part 7 Pop Up Box

<html>

<head>
<title>Javascript Project</title>
<script >

val_7= Hello;
val_9= World;

//alert(val_7+val_9);
name=prompt('Enter Your name', 'name' );
document.write('Hello dear <h2>'+name+'</h2> Welcome to my Site);
</script>

</head>
<body>
<button>Click here</button>
</body>
</html>


JavaScript  - Part 8 Math Operator & Assigning

<html>

<head>
<title>Javascript Project</title>
<script >
x= 7;
val_7= ++x;
document.write(' val_7 ');
val_1= 9;
val_2= 5;
val_3= 6;
val_3 *= ++val_2;
document.write(' val_3 ');
</script>

</head>
<body>
<button>Click here</button>
</body>
</html>

JavaScript  - Part 9 If Operator


<html>


<head>
<title>Javascript Project</title>
<script >

val_1= 9;
val_2= 5;
val_3= 6;

if (val_1== 9)
{
alert ('Everything is fine');

}

</script>




</head>
<body>
<button>Click here</button>
</body>
</html>


JavaScript  - Part 10 Comparison Operator

<html>

<head>
<title>Javascript Project</title>
<script >

val_1= 9;
val_2= 5;
val_3= 6;

if (val_2 < val_3)
{
alert ('Everything is fine');

}

</script>

</head>
<body>
<button>Click here</button>
</body>
</html>

JavaScript  - Part 11 If Else

<html>

<head>
<title>Javascript Project</title>
<script >

val_1= 9;
val_2= 5;
val_3= 6;

if (val_2 < val_3)
{
alert ('Everything is fine');

} else { 'Give book to his family members'};

</script>

</head>
<body>
<button>Click here</button>
</body>
</html>

JavaScript  - Part 11 Else if

<html>

<head>
<title>Javascript Project</title>
<script >

val_1= 9;
val_2= 5;
val_3= 6;

if (val_2 < val_3)
{
alert ('Give the book to boy');

} else if (val_1> val_3)
{

alert (' Give book to his elder brother');
} else if (val_1>val_2)

{
alert('Give book to mother');
} else

{
alert('Do whatever u want');
}

</script>






</head>
<body>
<button>Click here</button>
</body>
</html>


JavaScript  - Part 12 Logical Operators




<html>


<head>
<title>Javascript Project</title>
<script >
username='Devika';
password='test123';
email='gggttt@gmail.com';
if(username=='Devika'  && password='test123' || email='gggttt@gmail.com' && password='test123') {
document.write('You entered this page');

</script>






</head>
<body>
<button>Click here</button>
</body>
</html>


|| OR
&& AND
!  NOT




JavaScript  - Part 12 Logical Operators




<html>



<head>
<title>Javascript Project</title>
<script >
username='Devika';
password='test123';
email='gggttt@gmail.com';
if(username=='Devika'  )

{
document.write('You entered this page');
} else if  !(username=='Dvika') {

alert ('Enter right username');
} else if  !(username !='Devika') {

alert ('U again changed the value');
}

</script>




</head>
<body>
<button>Click here</button>
</body>
</html>


JavaScript  - Part 13 Nested If & Else

<html>


<head>
<title>Javascript Project</title>
<script >
shop= 'yes';
laptop= 'yes';
corei3= 'yes';
corei5= 'yes';
Ram_6GB= 'yes';
Ram_8GB= 'yes';
if (com_shop == 'yes') {
 if(laptop== 'yes') {
  if (corei3== 'yes'){
   if (Ram_6GB== 'yes'){

document.write ('Yay , we got our choiced laptop');


} else {document.write ('sorry there is no Ram_6GB');}



} else if (corei5== 'yes'){
          if (Ram_8GB==  'yes'){

{document.write (' there is  no corei3 but corei5 with ram_8GB');

} else if (ram_6GB== 'yes' ){document.write (' there is  corei5 laptop with ram_6GB');}


       else{

                document.write (' Sorry there is no corei5 laptop with ram_6GB');


}
    //{document.write (' there is  corei5');



}  else {document.write ('sorry there is no corei3');}



} else {document.write ('sorry there is no laptop');}



} else { document.write ('sorry there is no com shop');}

</script>






</head>
<body>
<button>Click here</button>
</body>
</html>

Javascript Part 17: Switch



<html>
<head>
<title>Javascript Project</title>
<script>
name = 'John';
switch (name){
case 'Devika': document.write('the name is Devika');
break;
case 'Kreetika': document.write('the name is Kreetika');
break;
case 'Radhika': document.write('the name is Radhika');
break;
case 'Madhu': document.write('the name is Madhu');
break;
default:document.write('there is no match of any case');
}


</script>
</head>
<body>
</body>
</html>



Javascript Part 18: For Loop



<html>
<head>
<title>Javascript Project</title>
<script>
for (x=0; x<10; x++){
document.write(x+'Hello World<br>');


}</script>
</head>
<body>
</body>
</html>



Javascript Part 19: Nested Looping



<html>
<head>
<title>Javascript Project</title>
<script>
for (y=0; y<10; y++){
document.write(''<b>+y+'Loop is working</b><br>');
  for (x=0; x<10; x++){
      document.write(x+'This is Sub Loop <br>');}
}</script>
</head>
<body>
</body>
</html>


Javascript Part 20: While Loop



<html>
<head>
<title>Javascript Project</title>
<script>
y=0;
while(y<10){
document.write(y+'This is  Loop <br>');
y++;
}</script>
</head>
<body>
</body>
</html>


Javascript Part 21: Do While Loop



<html>
<head>
<title>Javascript Project</title>
<script>
y=10;
do{
document.write(y+'This is  Loop <br>');
y++;
}
while(y<10)

</script>
</head>
<body>
</body>
</html>


Javascript Part 22: Creating Functions



<html>
<head>
<title>Javascript Project</title>
<script>
Function myFun() {

alert/document.write('This is my new Function');
alert / document.write(' 10+2 ');

}
myFun();
</script>
</head>
<body>
<button onclick="myFun();">Click here</button>


</body>
</html>