javascript refactor into functions
refactored javascript to use data attributes on submit buttons