So far we've worked with h t AML and CSX.
We know that both these programming languages instruct our web browser on how our web page should be
displayed.
We also learned that HDL and CSX are static languages that do not interact with users.
In this section of the course we'll be exploring a very powerful client side programming language known
as javascript.
When we say client side it means the language communicates with our web browser to allow user to web
page interactivity client side languages differ from server side languages such as BHP which will cover
later on server side languages communicate not with the web browser but with a web server.
JavaScript can be used to implement many different types of interactive features on a web page.
Let's take a look at some examples of JavaScript functions that interact with users
this javascript code calculates the amount of characters a user has typed into a text area.
Once you type in the line of text and press to calculate characters button you'll see that this line
of text has twenty three characters
this javascript code displays an error message.
If more than 10 words were typed into a text area
this is the pop up alert that appears if more than 10 words are typed in
this javascript code validates a form to make sure that the required fields were completed.
I purposely put an incorrect email address and left the other fields blank these fields are required.
So once we click submit we receive an error message saying that some of the required fields were not
completed.
This is done using JavaScript validation will score much more advanced validation techniques than this.
This is just a basic example
this javascript code ensures a user agrees to the terms and conditions of a web page in order to submit
a form
if I do not check off this checkbox here.
You'll notice I get a pop up message saying that we must check the box to continue.
And again this is another javascript function.
This is a slightly more advanced script.
It's a tic tac toe game and the purpose is to line up the x's or O's all in one straight line diagonally
horizontal your vertically
and so you can see if you lose a pop up message appears indicating that the game is over and you've
lost.
These are just a few basic examples of what JavaScript can be used for.
Javascript does have some limitations.
We've already touched on one in that it cannot be used to communicate with the web server.
Javascript cannot be forced onto a user's web browser either.
Remember javascript is a client side language meaning if your user has turned off javascript support
in their web browser your script will not work.
Also if the user's web browser is outdated it may not allow certain JavaScript functions to work correctly.
Note that almost all modern web browsers support javascript by default when installed.
Many people also confuse javascript with Java.
Note that these are two languages and they are not the same.
Java is a much more powerful and complex language in the same category is C and C++
javascript is an object oriented language.
This means that attributes of an object are contained within variables.
For example if we want to describe a person will refer to this person as the object we would typically
use attributes such as name height weight gender and age.
The values of these attributes will vary or differ from person to person.
Another word for attributes is variables.
These variables will contain the values for each person as we progressed through this dissection.
You'll gain a better understanding of this concept and the importance of working with variables.