1. Primero recojo la variable.
 2. Despues la imprimo en el campo de la modal.
 3. Finalmente llamo a la modal.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

    function guardar() {
      var txt=$("#texto1").val();
      $( "#texto2" ).text(txt);
      $( "#dialog" ).dialog();
    };

<!-- language: lang-html -->

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>jQuery UI Dialog - Default functionality</title>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
      <link rel="stylesheet" href="/resources/demos/style.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    </head>
    <body>
    <div>
      <input type="text" id="texto1" />
      <input type="button" value="enviar" onclick="guardar()" />
    </div>
    <div id="dialog" title="Basic dialog">
      <p id="texto2"></p>
    </div>
     
     
    </body>
    </html>

<!-- end snippet -->