I'm not sure I can answer your question directly but you will definitly need to use something other than javascript to interact with the database.
The most common way now days is to use php with a mysql database. They are most common because 1) both are open source 2) both have a lot of people using them so if you need help it is easy to find someone who can... on a forum like this.
The cool thing about php is that once you have contacted the database you can then use it to create dynamic html, javascript or even dynamic css as needed.
Check out php at
http://www.php.net
and MySql at
http://www.mysql.com