Dear, I've set the code to display a table in a dialog, but I would like to click on the icon to send the field name of the table to an input field of my form. Another detail, my dialog has a title that should be displayed as it is called, but this does not occur, the title is only displayed when I type some value in the "Search" field. Thanks in advance for your help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../../js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../../js/jquery-ui.js"></script>
<link type="text/css" rel="stylesheet" href="../../css/jquery-ui.css">
<script>
$(function()
{
$(".input-search").keyup(function()
{
//pega o css da tabela
var tabela = $(this).attr('alt');
if( $(this).val() != "")
{
$("."+tabela+" tbody>tr").hide();
$("."+tabela+" td:contains-ci('" + $(this).val() + "')").parent("tr").show();
} else
{
$("."+tabela+" tbody>tr").show();
}
});
});
$.extend($.expr[":"],
{
"contains-ci": function(elem, i, match, array)
{
return (elem.textContent || elem.innerText || $(elem).text() || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
$(function() {
$( "#dialog" ).dialog({
resizable: false,
height:250,
width:600,
modal: true,
autoOpen: false,
open: function(event, ui) {
$('.ui-dialog-titlebar-close').html('<span>X</span>');
$('.ui-dialog-titlebar-close').attr("title", "Clique aqui para fechar");
}
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
});
$(function() {
$( "#dialog2" ).dialog({
resizable: false,
height:400,
width:500,
modal: true,
autoOpen: false,
open: function(event, ui) {
$('.ui-dialog-titlebar-close').html('<span>X</span>');
$('.ui-dialog-titlebar-close').attr("title", "Clique aqui para fechar");
}
});
$( "#opener2" ).click(function() {
$( "#dialog2" ).dialog( "open" );
});
});
</script>
</head>
<body>
<div id="container">
<form action="../../function/funcoes.php" name="inserir_C" id="inserir_C" onsubmit="return validateForm()" method="POST" accept-charset="utf-8">
<div id="Cliente">
<fieldset id="Cliente">
<label for="TRANSP">
Transportadora:<input name="TRANSP" id="TRANSP" MAXLENGTH="20" value="" />
<a href="#dialog" id="opener">Dialog1</a>
<a href="#dialog2" id="opener2">Dialog2</a>
</label>
</fieldset>
</div>
</form>
<div id="dialog" title="Cadastro de Transportadora">
<form action="#" name="transportadora" id="transportadora" method="POST" accept-charset="utf-8">
<title>Cadastro de Transportadoras</title>
<fieldset id="Transportadora">
<label for="NOME_TRASNP">
Nome:<input type="text" name="NOME_TRASNP" id="NOME_TRASNP" value="" required/>
</label></br>
<label for="ENDERECO_TRANSP">
Endereço:<input type="text" name="ENDERECO_TRANSP" id="ENDERECO_TRANSP" value="" required/>
</label>
</fieldset>
<button type="submit" name="transportadora" >CADASTRAR</button>
</form>
</div>
<div id="dialog2" title="Procurar de Transportadora" >
<div id="table_dialog">
<input type="text" id="buscar" class="input-search" alt="listar" placeholder="Buscar nome" />
<table class="listar" style="border:solid 1px">
<thead><tr>
<th>ID</th>
<th>NOME</th>
<th>NOME2</th>
<th>ACAO</th>
</tr>
</thead>
<tbody>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
<tr>
<td>valor 1</td>
<td>valor 2</td>
<td>valor 3</td>
<td><a href="#">Enviar</a></td>
</tr>
</tbody>
</table>
</div><!-- fim table_dialog-->
</div>
</div> <!-- fim Container-->
</body>
</html>