Javascript to build an object from given elements using a GUI