A JavaScript Currency Conversion Script

It turns out that converting random numbers into formatted currency (with dollar signs, commas, and periods) is more difficult in JavaScript than I would have expected. There’s no built-in function for it, and it’s something I run into a lot. The function I wrote has worked well for me on a couple of projects now, so I thought I’d share it with you-all.

The little JavaScript function below does exactly one thing: it converts numbers (integers, floats, strings, whatever) into formatted currency. My example is in US dollars, but it’d be a quick change to make it work for other currencies as well.

The Problem This Solves

I wrote this script because I had to display dollar amounts in a “friendly” format in several places on a website, but I wasn’t being handed friendly numbers by the server. The numbers never included commas, of course. But there’s also the problem of whole-dollar and multiple-of-ten-cent amounts: I would have “500″ when the user would expect “500.00″, or “250.2″ when the user would expect “250.20″. Read the rest…

Cross-Browser Support for HTML5 Placeholder Text in Forms

Placeholder text in action

One of my favorite new additions to forms in HTML5 is the placeholder attribute. I love placeholder text because it can help make large, complex forms easier to navigate. Unfortunately, not every modern browser supports it yet. But I say, let’s use placeholder text NOW, for all browsers that support it, and fake the same functionality for legacy browsers.

Intelligent Select Box Filtering

Intelligent Select Box Filtering

These select boxes all contain the exact same security question. However, each question can only be selected once — we’re using jQuery to remove selected questions from all the other dropdowns.

Cross-Browser Rounded Buttons with CSS3 and jQuery

Cross-Browser Rounded Buttons

I was tasked with replacing several dozen Photoshop-generated rounded buttons on a large site with a flexible HTML/CSS/JS equivalent. I wanted it to be simple and leave the code as clean as possible. It also needed to work in all modern browsers. This is my solution.

Test for Border-Radius Support

border radius support

Rounded corners with border-radius are nice… when they work. Unfortunately, not all browsers support border-radius yet. Here’s a simple script that will let you test for border-radius support using jQuery.

I’m Attending AEA Seattle!

An Event Apart Seattle

Once I’m done stuffing myself with Easter-related goodies this Sunday, I’ll be catching a plane to Seattle to attend the An Event Apart conference. An Event Apart is two days of presentations on web design and the evolution and mastery thereof.

Show Your Google Analytics Top Content in WordPress

Google Analytics Top Content on Wordpress

If you’re a typical blog owner, one of your biggest goals is to keep visitors browsing your site. One good way to do that is by showing off your most popular posts. Here’s a way to show your Top Content from Google Analytics on your WordPress blog by piggybacking on an existing plugin.