Posts Tagged ‘javascript’

Keeping Entered Values when Reporting an Error

Friday, July 25th, 2008

Sometimes the solution to a problem is extremely simple but not very obvious until you know what it is. One such simple solution relates to not losing the values already entered into a form when you want JavaScript to report validation errors.

Keeping Entered Values when Reporting an Error

p.s. why do so many people insist on misspelling lose (opposite of win) as loose (opposite of tight). Are people these days so reliant on spell checkers that they have forgotten how to spell even simple words?

JavaScript Dates

Tuesday, July 22nd, 2008

Yesterday we looked at all the methods that JavaScript provides for working with arrays. Today we take a similar look at dates and the ways that JavaScript can work with dates and times.

JavaScript Dates

JavaScript Arrays

Monday, July 21st, 2008

How do you define arrays in JavaScript? Well there are several different ways to do so.

How can you manipulate the content of your JavaScript arrays? Again there are a whole series of different methods available to make it easy to work with arrays in JavaScript.

This tutorial/reference shows you all the alternatives and how to use them in your code.

JavaScript Arrays

Dynamic Dropdown Boxes

Sunday, July 20th, 2008

One way in which JavaScript can make your forms more user friendly is where you have multiple dropdown lists where what is a valid selection in one list is dependent on what is selected in another list. Let’s take a look at how you can use JavaScript to link two dropdown lists together so that the entries displayed in the second list are dependent on what is selected in the first list.

Dynamic Dropdown Boxes

Note that theses are dropdown lists, not combo boxes, HTML does not have a tag for generating a combo box. A combo box is a combination of a dropdown list and a text input field since your visitor can either select an entry from the list or type their own value in a combo box.

Find on this Page

Thursday, July 17th, 2008

Just about all browsers have a find on page option in the menu and so adding an equivalent option using JavaScript may not appear all that useful. It doesn’t work completely the same way as the built in ones do though since it uses a separate browser window rather than a dialog box and therefore doesn’t need to be closed in order to continue interacting with the page.

Find on this Page

Your Favourites

Saturday, July 5th, 2008

This example of my cookie toolbox in action allows you to set up a web page on my site that links to your fifty favourite web pages.

Your Favourites

A Cookie ToolBox

Friday, July 4th, 2008

Cookies are the main way of retaining information between one web page and the next and the only way to retain information between different browser sessions. Cookies are supported by both JavaScript and server side processing. Cookies are however limited in the amount of data they can store. Each domain can store up to 20 cookies with up to 4k of data in each with a maximum of about 300 cookies being able to be stored in total.

By using my cookie toolbox you make processing of cookies in JavaScript easier as well as being able to store an array of values into a single cookie.

A Cookie ToolBox

Limiting Textarea Text

Wednesday, July 2nd, 2008

Unlike normal input text fields where you can specify a maxlength attribute, there is no HTML equivalent for textareas. Instead if we want to limit the amount of text that can be entered in the browser rather than just truncating the textarea after it is submitted we need to use JavaScript.

Limiting Textarea Text