Move javascript to an external file.
Fix SQL.