Remove link outlines

You know those dotted outlines that Firefox puts on links, often breaking the aesthetics of image links?

a { outline:0; }

Posted 02 May 2008, tagged with css firefox

Graceful degradation of submit

Instead of using type="image", use a normal type="submit" and apply the image with css background. To get rid of the text, use a negative text-indent on rational browsers or a combination of display:block, overflow:hidden and font-size:1000em (better than font-size:0, trust me).

Par examplais..

Go ahead, disable CSS and see for yourself.

Posted 02 May 2008, tagged with html css a11y

IE hide select option

There is no way of setting display:none or similar on a select option in IE (6 + 7). Can't we all just be friends?

Solutions to follow. There are probably two good ways to solve this: use AJAX to recreate the list after each click, or an Array of data structure Objects on page in javascript to do it (my preference).

After writing that data somewhere, do some jQuery like

$(#first select).change(function() {
  $(#second select).html('<option>Select</option>');
  // clears the list and sets a default label

  for (var i=0; i<arr.length; i++)
    if ($(this).val() == arr[i].some_code)
      $(#second select).append('<option value="' + arr[i].sub_code
        + '">' + arr[i].sub_label + '</option>');
});

Not very exciting. It's an ending, that's enough.

Posted 28 Apr 2008, tagged with ie ie6 html javascript

Alter column PSQL

Note: spend more time on the database structure in the first place.

ALTER TABLE product
  ADD COLUMN product_price
  CHARACTER VARYING(8)
  NOT NULL
  DEFAULT 0;

and don't forget to

UPDATE product SET product_price=0;

Oh crap too small

ALTER TABLE product
  ALTER COLUMN product_price
  TYPE CHARACTER VARYING(64);

Posted 24 Apr 2008, tagged with postgresql sql

Select random

Revisiting the ORDER BY RAND() for MySQL, the equivalent for PostgreSQL is ORDER BY RANDOM(). Sigh.

Posted 17 Apr 2008, tagged with mysql postgresql