Submit buttons were reloading the page and preventing javascript database to work correctly.