Pull into text field

Like from

<div class='panel' style='width:200px;'  id='d_{$row['id']}'>
{$row['id']}  {$row['name']}<div class='selo' >

Pull into <input id="tex" type="text" name="tex">field {$row['name']}into modal window?

require_once "conf.php";
$zapros=mysql_query("select * from spr_otdel") or die (mysql_error);
while ($row=mysql_fetch_array($zapros)){
echo "
<div class='panel' style='width:200px;'  id='d_{$row['id']}'>
{$row['id']}  {$row['name']}<div class='selo' ><a href='#' class='btn-delete'  onclick='return delet(\"{$row['id']}\")'></a> | <a href='#' class='edit'></a></div></div>";
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery.ui.dialog.js"></script>
<style type="text/css">
body {
    font-size: 62.5%;
.panel {
    background: #ffffff;
    padding: 10px 20px 10px;
    position: relative;
    border-top: solid 1px #ccc
.alt {
    background: #f5f4f4;
.selo {
    font-size: 8pt;
 <script type="text/javascript">
        $(".panel .edit").click(function(){
    $(function() {
        $( "#dialog" ).dialog();
$( "#dialog" ).dialog({ buttons: [
        text: "Ok",
        click: function() { $(this).dialog("close"); }
function delet(id) {
        $( "#del" ).dialog({ 
        title:" ",
        "": function() {
        $("#d_"+id).animate({ backgroundColor: "#fbc7c7" }, "fast")
        .animate({ opacity: "hide" }, "slow");
        "": function() { $(this).dialog("close"); }
        return false;
<div id="del" style='display:none;text-align:center;font-size:10px;'>
<div id="dialog" style='display:none;font-size:10px;' title=''>
<input id="tex" type="textarea">

Answer 1, authority 100%

Include jquery library

Js code:

var data;

The second line passes to the data variable everything that is enclosed in the ‘div’ tag of the ‘panel’ class (Thanks to the jquery library).
The third line writes the ‘data’ variable to the input with “id=’text'”

but better like this: