Replace Default Field Values with Labels

Lots of times, it makes sense to pre-populate a form field with some text to guide the user. Usually you see this when space is limited, and the site tries to use the field’s value as a label. However, the field’s value isn’t the label— it’s the value. We see this often when a form has little real estate available to it, or sometimes when the designer doesn’t want to clutter up the interface with extra text. Continue reading “Replace Default Field Values with Labels”

Creating a Tabbed Interface with CSS and jQuery

Here’s a piece I put together recently for a client who wanted a tabbed interface on one of their pages. My goal in doing it was to make it as accessible and semantic as possible. One requirement I gave myself was to NOT use redundant elements (like one list for the tabs, and another for the content).
Continue reading “Creating a Tabbed Interface with CSS and jQuery”

A Table-Less Product Grid

Since switching from the written content-heavy world of academia to the more photo and data-driven world of retail, I’ve been inundated with tables. There’s really nothing new about this— tables have been the web designer’s best friend since 1996. But as the web matures, we’re realizing that tables needn’t be (and shouldn’t be) used for layout purposes, but rather for the tabular data that the W3C had intended them to be used.

Continue reading “A Table-Less Product Grid”

Easier Dates in PHP

So, much of the work I do involves web apps that use MySQL behind them, and more often than not, I’ve got to deal with dates and date math. PHP has its handy mkTime() function that will return Unix time given a funky order of time chunks (hh, mm, ss, mo, dy, yr). But I could rarely ever remember that particular order, and I always hated trying to parse out my MySQL date (YYYY-MM-DD) into the necessary pieces.

Alas, makeTime() was born:

function makeTime($date) {
	// takes YYYY-MM-DD HH:MM:SS, or some combination thereof and returns mktime
	$length = strlen($date);
	
	$isdate = false;
	$istime = false;
	
	$sArray = explode(" ", $date);
	if (sizeof($sArray) > 1) {
		// explode found a " ", and we now have an array w/ length > 1
		$dateString = $sArray[0];
		$timeString = $sArray[1];		
	} else {
		// explode didn't find a " ", and we have an array w/ length == 1
		// check to see if it's a date or a time value
		if (strstr($sArray[0], "-")) {
			$dateString = $sArray[0];
		} else {
			$timeString = $sArray[0];
		}
	}
	
	if (($dateString) && (sizeof($dateString > 0))) {
		// we have a date string, parse it out
		$dArray = explode("-", $dateString);
		$yr = $dArray[0];
		$mo = $dArray[1];
		$dy = $dArray[2];
	}
	
	if (($timeString) && (sizeof($timeString > 0))) {
		// we have a time string, parse it out		
		$tArray = explode(":", $timeString);
		$hh = $tArray[0];
		$mm = $tArray[1];
		$ss = $tArray[2];
	}
	
	$hh = ($hh) ? $hh : "00";
	$mm = ($mm) ? $mm : "00";
	$ss = ($ss) ? $ss : "00";
	
	$yr = ($yr) ? $yr : date("Y");
	$mo = ($mo) ? $mo : date("m");
	$dy = ($dy) ? $dy : date("d");
	
	return mktime($hh, $mm, $ss, $mo, $dy, $yr);

}

Enjoy!