Learn All Programming and Scripting languages inside Our Blog, learn all BCA, MCA, B.E.IT, B.E.CE programs here Our Youtube Channel: youtube.com/avadhtutor
Sunday, 24 January 2021
Tuesday, 19 January 2021
JavaScript Events
JavaScript Events
onclick(): click on object (elements) then event are occurred
<input type=button value="click me" onclick="alert(' Welcome to Onclick event')">
________________________
ondblclick(): ondblclick event occurred when two time click on object for example:
<script>
function sum()
{
a= 20;
b=30;
c = a+b;
document.write(c);
}
</script>
<input type=button value="addition" ondblclick="sum(); ">
___________________________
onmousemove() or mouseover:
- this event is working with your cursor is going inside a Object then Mousemoved are Fire
- if your cursor are go inside an elements then move event occured
<script>
function news()
{
alert("todays we are worked with JavaScript events \n All Subjects are Important for Future");
}
</script>
<br><br>
<p style="background-color:yellow;" onmousemove="alert('this is a Mouse Move Event');">welcome</p>
<br><br>
<input type=button onmousemove="news();" value="NEWS">
Mouseover():
<script>
function abc()
{
alert("Welcome to Mouse Move event");
}
function xyz()
{
alert("Welcome to Mouse Over Event");
}\
</script>
<input type=button onmousemove="abc();" value=" Mouse Move ">
<input type=button onmouseover="xyz();" value=" Mouse Over ">
_____________________
MouseOut(): mouse out is working with if you are loss or leave the cursor on object
<script>
function test()
{
alert("This is a Mouse Out event");
}
</script>
<input type=button onmouseout="test();" value=" Mouse Out ">
___________________________
onfocus(): this event occurred when you tab or click on object
- The onfocus event is most often used with <input>, <select>, and <a>.
<script>
function y()
{
alert("Please Not Write Content Here");
document.frm.t1.value="Avadh Tutor";
}
function z()
{
document.frm.t2.value="";
}
</script>
<form name="frm">
<input type="text" name="t1" value="" onfocus="y();" ><br>
<input type="text" name="t2" value="" onfocus="z();">
</form>
Example 2: Onfocus with Color Change
<script>
function setStyle(x)
{
var a = document.getElementById(x);
document.getElementById(x).style.background="black";
document.getElementById(x).style.color="white";
document.getElementById(x).style.fontSize="10";
}
</script>
First name: <input type="text" onfocus="setStyle(this.id)" id="zxcvxx">
<br />
Last name: <input type="text" onfocus="setStyle(this.id)" id="cvx">
__________________________________
onkeyup(): when your key is up inside a keyboard
- when the user releases a key
<script>
function y()
{
alert("Please Not Write Content Here");
document.frm.t1.value="Bhavin";
}
function z()
{
document.frm.t2.value="";
}
</script>
<form name="frm">
<input type="text" name="t1" value="" onkeyup="y();" ><br>
<input type="text" name="t2" value="" onkeyup="z();">
</form>
__________________________
onChange(): when the value of an element has been changed, For radiobuttons and checkboxes, the onchange event occurs when the checked state has been changed, onchange event occured when you change your data (value)
Example :
<script>
function abc()
{
alert(document.frm.product.value);
}
</script>
</head>
<body>
<form name="frm" method=post>
<select name="product" onchange="abc();" >
<option value="this">INDIA</option>
<option value="is">B</option>
<option value="best">C</option>
<option value="you">D</option>
</select>
</form>
___________________________________________________
onSubmit(): onSubmit event is Work with form with Submit Button, When you click on Submit then onsubmit event will be fired
Example:
<script>
function abc()
{
alert(document.frm.nm.value);
alert(document.frm.pass.value);
}
</script>
<form name=frm onsubmit="abc()" method=post>
name<input type=text name=nm value="">
password<input type=password name=pass value="">
<input type=submit value="click now" >
</form>
_____________________________________________________
onBlur() : most often used with form validation code
<input type="text" id="myInput" onfocus="focusFunction()" onblur="blurFunction()" placeholder="Enter Your Name">
<script>
function focusFunction() {
document.getElementById("myInput").style.background = "tomato";
}
function blurFunction() {
document.getElementById("myInput").style.background = "blue";
}
</script>
_________________________________________
onReset(): occurs when a form is reset (clear).
Example :
<form onreset="my()">
Enter name: <input type="text" placeholder="Enter Name">
<input type="reset">
</form>
<script>
function my() {
alert("The form was reset");
}
</script>
JavaScript Array
What is Array:
- array is a single variable that is used to store different elements.
- by default index of array is 0
- Array is stored multiple values inside a Single Variable Using New Keyword
____________________________________
Difference Between Array and Variable
- Array is Stored Multiple Values inside a Single variable using New Keyword
- Variable is Stored only Single value At a time
Example of Variable and Array:
<script>
//variable is store run time only one value at a time
a = 1,2,3,4;
document.write(a);
document.write("<hr>");
//array
a = new Array(10,20,30,40,100);
document.write(a);
</script>
Output of variable:
1
Output of Array:
1,2,3,4
_______________________________________________
Index wise Array Printing:
<script>
//index wise array fetch
a = new Array(10,30,40,50,100)
document.write(a);
document.write("<hr>");
document.write(a['1']);
document.write("<hr>");
document.write(a['4']);
</script>
Output:
10,30,40,50,100
_____________
30
_____________
100
______________________________________________________
Array With ForLoop:
<script>
jay = new Array("jayesh","kishan","nayan",30,40);
document.write(jay[0]);
document.write("<hr>");
for(i=0;i<=4;i++)
{
alert(jay[i]);
document.write("Your data is:"+jay[i]+"<br>");
}
</script>
Sunday, 10 January 2021
JavaScript Dialog Boxes
JAVASCRIPT DIALOGBOX
There are three types of Dialog Boxes are available in java Script
- Alert()
- Confirm()
- Prompt()
___________________________________________________________
alert() : An alert box is used if you want to sure information comes through to the user.
Example 1:
<script>
document.write("Dialog Boxes");
alert("Welcome to My BOX");
</script>
Example 2: Addition
<script>
a = 10;
b= 20;
c = a+b;
document.write(c);
alert("Addition is : "+c);
</script>
Example 3: alert with Button
<input type=button value="Click Me" onclick="alert(' Welcome to JavaScript')">
<br><br>
<input type=button value="Register" onclick="alert(' Welcome to MY Alert BOX')">
<br><br>
<input type=button value="HI Friends" onclick="alert(' This is Scripting Language')">
<br><br>
__________________________________________________
Confirm(): A confirm box is often used if you want the user to verify or accept something. confirm box provide two buttons OK and Cancel
Example:
<script>
alert("Thanks for Visit My WebSite");
confirm("Are Your Sure to Delete ....");
</script>
______________________________________________________
Prompt(): A prompt box is often used if you want the user to input a value before entering a page. prompt box provide input box with OK and cancel button when click on OK then return return if you click on cancel button then return false
Example 1:
<script>
//getiing a values from the user using Prompt Box
prompt("Enter NO");
</script>
Example 2:
<script>
i = prompt("Enter Your Name");
document.write("Your Name is :"+i);
</script>
Example 3:
<script>
//prompt getting a by default values are string
//Converting a String to Integer using parseInt()
a= parseInt(prompt("Enter No"));
b = parseInt(prompt("Enter No2"));
c = a+b;
document.write("Addition is : "+c);
</script>
Conditional Statement Using Java Script
Java Script Conditional Statement
IF... ELSE Statement:
The if/else statement executes a block of code if a specified condition is true ther wise false.
_____________________________________________________
IF ..... ELSE IF.....
Example:
<script type="text/javascript">
var a=parseInt(prompt("Enter No A",""));
var b=parseInt(prompt("Enter No B",""));
if(a<b)
{
document.write("A Is Less Then Of 20 <br>");
}
else if(a==b)
{
document.write("A is equal to B <br>");
}
else if(a<50)
{
alert("hello");
}
else
{
alert("this is a alert box");
}
</script>
__________________________________________________________
Switch Statement using Java Script:
Example:
<script type=text/javascript>
var d=new Date();
abc=d.getDay();
a = parseInt(prompt("enter Switch",""));
switch (a)
{
default:
alert("no case define");
break;
case 0:
document.write("Hello");
break;
case 1:
document.write("Monday");
break;
case 2:
document.write("welcome");
break;
case 3:
document.write(" Tamene Game e rakho");
break;
case 4:
document.write("Sleepy THUS");
break;
case 5:
document.write("Sleepy FRI");
break;
case 6:
alert("end of");
break;
}
</script>
___________________________________________________________
Learn All programming and Scripting languages with youtube.com/avadhtutor/
What is While Loop? Example of While Loop in Java Script
WHILE LOOP
- A while loop in C programming repeatedly executes a target statement as long as a given condition is true.
- The condition may be any expression, and true is any nonzero value. The loop iterates while the condition is true.
______________________________________
Syntax of While Loop:
var initialization;
while(condtion)
{
Statement
increment/ decrement
}
_______________________________________
Example of While Loop:
<script type="text/javascript" language="javascript">
//while loop
i=0;
b=0;
while (i<5)
{
document.write("The number is " + i)
document.write("<br />");
while(b<=3)
{
alert(b);
b++;
}
i++;
}
</script>
_______________________________________
learn All Programming and Scripting languages with youtube.com/avadhtutor
Java Script operators
JAVA SCRIPT OPERATOR
Following Operator Provide by Java Script: Arithmetic, Assignment, Comparison, Logical
Friday, 8 January 2021
Java Script ForLoop Example
Variable Declaration Using Java Script
Java Script variables
Variable are containers that can stores user define values
Define variable using var sign
without any sign variable accessible are flexible and usable
______________________________________________________
Example 1: Simple variable Declaraton
<script>
a = "jay";
document.write(a);
</script>
Example 2: Simple Calculation
<script>
a=20;
b=30;
c = a+b;
document.write(c);
</script>
Example 3: Concatenate a variables (Merge)
<script>
var a="jay";
var b="raj";
document.write(a+"<br>"); //single variable access
document.write(b+"<hr>"); //single variable access
/* Concating a Variable (Merge) */
document.write(a,b); //merge variable using (,) sign
document.write(a+b); //merge variable using + sign
</script>
Example 4: Simple Calculations with variable with HTML Formatting
<script>
x= 30;
y = 40;
z = x+y;
document.write("<font color=red>SUM IS: </font><font color=green>",z +"</font><br>");
z = x-y;
document.write("<font color=red>SUB IS: </font><font color=green>",z +"</font><br>");
z = x*y;
document.write("<font color=red>MUL IS: </font><font color=green>",z +"</font><br>");
z = x/y;
document.write("<font color=red>DIV IS: </font><font color=green>",z +"</font>");
</script>
___________________________________________
All Programming languages step by step with youtube.com/avadhtutor/playlists/
Simple Example of Java Script
Simple Example are Listed Here
Example 1: simple printing Statement, java script with html, java script with CSS
<script>
document.write("Hello Welcome");
document.write("<marquee>welcome to JS</marquee>");
document.write(" <p style='color:red; background-color:blue; '>welcome CSS</p> ");
Introduction of Java Script
: Introduction of JavaScript:
What is JavaScript:
JavaScript is the Programming Language for the Web.
JavaScript can update and change both HTML and CSS.
JavaScript is the world's most popular programming language.
JavaScript is easy to learn.
JavaScript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow client-side script to interact with the user and make dynamic pages. It is an interpreted programming language with object-oriented capabilities.
________________________________________________________
ADVANTAGES OF JAVA SCRIPT:
Less server interaction - You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
Immediate feedback to the visitors - They don't have to wait for a page reload to see if they have forgotten to enter something.
Increased interactivity - You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
Richer interfaces - You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.
Easy to Use : Java Script Provide User Friendly Environment
_________________________________________________________
DISADVANTAGES OF JAVA SCRIPT:
Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reason.
JavaScript cannot be used for networking applications because there is no such support available.
JavaScript doesn't have any multi-threading or multiprocessor capabilities.
___________________________________________________________
Steps to create First Program in Java Script:
Step 1: Open Any Editor Like (Notepad, Notepad ++, Sub Lime ....)
Step 2: Write Below Code inside Your Page
<script>
document.write("welcome to JavaScript");
</script>
_______________________________________________________________
Save this File as a 1.html






