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