That's simple. Every HTML element has a name, accessible from Javascript. Every HTML form element has a value, which you can get or change. And HTML elements has event reaction parameters in their tags. So, see example:
This form gets the value from filed 1 and passes it to the field 2 with a small change:
And here is the code to implement this: