Getting data from a dialog

Enter some text and close me.


The jQuery Code START
    
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

<script type="text/javascript">
  $(document).ready(function() {
    $("#dialog").dialog({
      buttons: {"Ok": function() { $(this).dialog("close"); } }, 
      beforeclose: function(event, ui) { 
      $("#results").text("You entered " + 
      $("#text").val()) 
     }
    });
  });
  </script>
</head>
<body>
  <h1>Getting data from a dialog</h1>
    <div id="dialog" title="Dialog Title">Enter some text and close me.
      <input type="text" id="text"></input>
    </div>
    <div id="results"></div>