Javascript while loops Tutorials - JavaScript Functions Tutorial
JavaScript Functions?
Functions are used for doing repeated task over and over again, its a piece of code on the your page that sits dormant until it is called. Functions do not execute when a page loads, its used when an event occurs. Functions are stored in the head of a document.
Sample Pseudo Code:
function sendMessage() {
code to be executed
}
The web page below contains a button, when the user clicks the button the sendMessage function is called. An alert message is then thrown from the sendMessage function - try this code out.
Example:
In Javascript it is quiet easy to pass values to functions, you add the value you want to pass into the function call. See the example below
The output message thrown would now be Hello Fergal Your Password is the password assigned to the php variable $password
The output here is the same as for the FOR loop with 9 being the last number outputted.
![]() |
