There is a system table called pg_database which contains all of the database names. You should simply be able to do a "select datname from pg_database" to get the list. If you want to use these from the web I might suggest making a view out of that query and granting select permission to the view rather than to the actual system table itself.
Hope that does what you want.
Tim