Javascript function to build form html