- Add form values to .details using document.createElement and appendChild, instead of innerHTML.
- Break out some of this functionality into a separate function.
- Do not hard-code the names of the fields in your JavaScript. Loop over all the elements in the form.