Skip Navigation | Home | Code Samples | Articles | Links | About | Contact Me | Make a Payment

JavaScript

Here are some JavaScript snippets, examples, etc. that I use in my day to day development.

URL Object
This bit of code will come in really handy for those developers with lots of server-side programming experience, but are somewhat new to JavaScript. It will break the name/value pairs in the query string and make them available as properties of a url object. [view]
CGI Object
This bit of code will come in really handy for those developers with lots of server-side programming experience, but are somewhat new to JavaScript. It will convert things like urls, cookies, user_agent string, referer, etc. into properties of a single object. [view]
Cookie Object
This bit of code will come in really handy for those developers with lots of server-side programming experience, but are somewhat new to JavaScript. It will take document.cookie and create a cookie object where the name/value pairs are properties of this cookie object. [view]
Select Calendar
This code sample combines three select lists with some scripting to give your users a smart date selection mechanism. [view]
Sorting/Ranking Options within Optgroups
This page contains functions that make it possible to change the order of options in a select list. Unlike most other examples I've seen available, this sample works with not just one option selected, but multiple options, whether or not the group of selected options are together or have gaps of unselected options between some of them. Additionally, the movement is options is restricted to the group they belong to -- i.e. you can't move an option out of one group and into another. This code sample also contains code necessary to select all the options in the select so that all are submitted to the server. [view]
Select Search
Extend the functionality of your pulldown menus by giving your users an additional way to find options. [view]
toggleDisplay() -- Toggling the display property of an object
Do you write a custom function (or worse) every time you need to provide "expand/collapse", "hide/show", etc. functionality? This function should fix you up nicely. [view]
Checkbox Check All/Indeterminate
This code sample addresses the common question of how to write a function that gives the user the ability to check or uncheck all checkboxes in a group. This particular sample excels over others in that the state of the "control" checkbox changes to indicate the state of group of check boxes. If none are checked the "control" checkbox is unchecked. If more than one, but not all are checked, the "control" checkbox is set to an indeterminate state. if all the checkboxes are checked the "control" checkbox is checked. [view]
LABEL IMG Fix for Win/IE
This code sample addresses the Win/IE bug where images within a label element trap the click on the image and the associated checkbox/radio button don't get checked as they should. [view]
CHMOD
Ever wanted to give your users the ability to set permissions on files/folders via a web-based interface? This code sample is a complete working bit of code to do just that. Or, if you're constantly asking yourself what 777 or --w-rwx-w- means, this code sample can help you with that too. [view]
Accessible Bookmarklets
Bookmarklets are inherently inaccessible. While they're generally something that only advanced users encounter, there's no reason why we, as developers, can't make them easier to work with for those who might have JavaScript disabled, for whatever reason. [view]