Categories
JavaScript

Mutually exclusive checkboxes

Sometimes it’s just not worth arguing. Super quick and nasty solution to a request for checkboxes that are mutually exclusive: one or no checkboxes can be selected. I know, I know; radio selector, right? Some HTML: <fieldset> <label for=”ResponseSaidCBY”>Yes</label> <input type=”checkbox” id=”ResponseSaidCBY” /> <label for=”ResponseSaidCBN”>No</label> <input type=”checkbox” id=”ResponseSaidCBN” /> </fieldset> and some JavaScript: function clickYes() […]

Categories
JavaScript

Submit a form with a radio button using Javascript

My boss (bless his little cotton socks) wanted me to implement some code that submitted a form when the user changed the selection in a set of radio buttons. This seemed fairly simple: surely I could just do something like: After writing a separate function and calling it on the onClick method, and after trying different […]

Categories
JavaScript

Reloading a page with Javascript and your cache

I was caught out using Javascript’s location.reload(true); recently. I have a web-page which is destined to be displayed in a public area on a large screen, which unfortunately has a LARGE, static background image (not my design – promise!). The page must reload fairly frequently, and I don’t want the background image disappearing while it […]

Categories
JavaScript

Google Code Prettify

I have played with various WordPress plugins for code syntax highlighting, but recently helped answer a query with regards syntax highlighting in other projects using Google Code Prettify. If you store your code samples in a MySQL database, the trick is to store them as html entities. In other words, the following PHP code: <?php //comment […]

Categories
jQuery

JSFiddle

JSFiddle is an incredibly useful on-line tool to test (or fiddle with) your JavaScript, HTML, and CSS code. You can test, save, share, embed, and even collaborate. Seeking help — or even better — offering a solution on StackOverflow? Use JSFidlle and post your work! Below is my first attempt!

Categories
Misc Code

Drag-and-drop sortable list using Script.aculo.us

This is some quick work I did quite some time ago when assessing different JavaScript libraries. This demo uses Script.aculo.us with a PHP / MySQL back-end. The drag-and-drop interface allows the sorting of the list items. I notice on the website that the current version is dated 23 December 2010. I am guessing it is […]