Introducing JavaScript

JavaScript has changed a great deal since it was first introduced but many sites still use outdated techniques. There are even lots of JavaScript tutorials on the web that show you how JavaScript should be written so that it can work in Netscape 2 rather than so that it will work in modern browsers. As a result there are many people who are writing what they think is JavaScript but where what they are producing is more suited to the 20th Century than to the 21st.

Beginners should work through all the basic examples prior to moving on to the other examples which cover separate aspects of JavaScript in more detail.

Most of the JavaScript examples here will work in IE5+, Opera7+ and all versions of Firefox, Safari and Chrome. Those commands introduced in ECMAScript 5 in 2011 are being added to the site where they are supported by the latest version of all popular browsers. Where these new commands are not supported by IE8 or IE7 that information is included in the text since those two browsers might still have to many users for you to ignore. So few people using other browsers fail to keep their browser up to date that lack of support in older versions of other browsers will not have any significant affect.

A few examples of what we can expect from EcmaScript 6 are also included in their own section so you can see the direction that JavaScript is moving in - even though it will probably be quite a while before we can use those commands.

There is a link to jsBin at the bottom right of all the pages. This site provides an easy way to test your JavaScript code online without needing to create an entire web page to run a simple test.

Creating Input Fields

It is when you come to actually trying to create input fields from JavaScript that you discover one of the biggest differences between JavaScript and jScript that cannot be detected using feature sensing. While you can create the input field and then give it a name in JavaScript, jScript requires that you use a special […]

Updating Textareas

A textarea is a bit different from most other form fields in that instead of having a value attribute to contain the original value, it has both an opening and closing tag and the original value goes in between. Surprisingly though JavaScript allows you to access that content via the value property just as if […]

defaultValue and defaultChecked

Often form fields have a special value displayed in them at the start to assist the person filling out the form to know what to enter there. When testing if the person has filled out the field we need to disregard this default value. JavaScript makes it easy to check if the original value is […]

Changing Values in Forms

The main way in which form fields differ from the other elements in a web page is that form fields have a lot of additional properties that other elements don’t have. You can change the properties/attributes of form fields the same way as for any other elements with a couple of exceptions that we will […]

Accessing Radio Buttons

The one type of form field that we need to access differently than the rest is radio buttons. On the server where only the value of the selected radio button is passed making it no different from regular input fields. In JavaScript though we have a nodelist of all of the buttons in the group […]

This site is © copyright Stephen Chapman - Felgall Pty Ltd 2011-2014.

Privacy Policy | Terms and Conditions

You are welcome to use any the example JavaScript from this site in the scripts for your site or any that you develop for others but may not use the longer example scripts that contain a copyright notice in any other way without permission.