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+ (provided you use a deprecated MIME type - otherwise IE9 through 11 only), Opera7+ and all versions of Firefox, Safari, Vivaldi and Chrome. Those commands introduced in ECMAScript5.1 in 2011 have been added (if I have missed any please let me know). Those commands introduced in ECMAScript2015 and ECMAScript2016 are currently being added (there are lots of them for 2015 so it may take some time but then most current browsers do not yet support them all anyway). Where these new commands are not supported by IE8 that information is included in the text - just in case you still have lots of people using that long unsupported browser. So few people using other browsers fail to keep their browser up to date that lack of support in older versions of other browsers should not have any significant affect.

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.

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 […]

Access The Form Itself

We don’t need a name or an id on the form tag itself when defining a form. The server side processing doesn’t use the name of the form, just the names of the individual fields and JavaScript can easily access the form itself from any of the fields contained within it.

Access Form Fields

Moving on from tables to the other part of the web page that has slightly different requirements for the Document Object Model – the form. The easiest way to handle most of your JavaScript to form field interactions is to give the form fields an id each – that way the name can be used […]

Creating Tables

I have seen masses of complicated code involving a huge number of createElement calls used by beginners attempting to create tables from JavaScript but who have not learnt just how simply you can create an entire table in JavaScript by using the table specific properties and methods. The only elements in the entire table where […]

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

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.