This example uses shows how to gather some data from the user and then how to create a popup window with dynamic response data More examples are in the same directory
See the associated JS code. In both the HTML and JS file, please have a look at the comments. They will help you with reuse.