I am in a situation, where I need to convert my form filled data to a text before submitting. 

Like for example, the form may have a name field and an email field. I will fill the form with details, then when I click export as text, I need to get the contents of the html in text format 

```html
name = <input type="text" name="name" /> <!-- user enters "john" -->
email = <input type="text" name="email" /> <!-- user enters a@b.com -->

```

when I export I need 

```
name = john
email = a@b.com

```

Currently, I am using this code to convert. But the problem is, once I convert I am not able to get back to previous state. 

```
$("#btn").click(function(){
   $('.replace').replaceWith(function(){
       return this.value
    });
});

```

So, what I thought was, I will display the output in a div tag. But if I try 

```
document.getelementByID("parentdiv").value

```

I am unable to get the form values. 

Any suggestions please?

**Update:**

serialize is not working as expected. The above one is a small example. The form is so complex and I need to visually render the form values to its labels.