Javascript Database Code