Archive for May, 2008

favorite php function – shuffle()

May 13, 2008 Leave a comment

How awesome is that. I know I’m a doof.. but having the shuffle() function to randomize elements in an array is just great. It’s not even array_shuffle() or array_randomize() — it’s just plain shuffle(). Cute.

Categories: Uncategorized Tags:

jquery add a table row

May 13, 2008 4 comments

I needed to add a table row to the bottom of a form.  Jquery to the rescue. The form has a series of rows that record a start date and an end date.  But the user can opt to create more input rows if they so choose, kicking off a little dhtml to extend the size of the form.

Here’s what I ended up using to add a row to the bottom of the table:

function onAddDateRange() {
var lastRow = $(‘#date_ranges tr:last’).clone();
var id = parseInt($(‘.id’, lastRow).html()) + 1;
$(‘[name]:first’, lastRow).attr(‘name’, ‘week_start_’ + id);
$(‘[name]:last’, lastRow).attr(‘name’, ‘week_end_’ + id);
$(‘.id’, lastRow).html(id);

Categories: Uncategorized Tags: