Dynamically create input fields in js, improve ui behaviour