In my page there are fields that are tabulated data, where the user should select an existing data in the table
For a simple case, I'm using <select><option>
of html
fed with a table reading via php
, however I came across a case where the data in a table is many. With this the combo gets very large and the page gets heavy to load.
I would like to know how to insert a sort of button that calls a dialog
that will display the table with values, where the user can click on the data and it will be sent to form
.
$ (function () { $ ("#datepicker") .datepicker (); }); $ (function () { $ ("#tabs") .tabs (); });
<?php
require_once('../../function/funcoes.php');
?>
</head>
<title>Dober System</title>
<body>
<div id="container">
<form action="../../function/funcoes.php"" name="inserir_C" id="inserir_C" method="POST">
<div id="Cliente">
<fieldset id="Cliente">
<legend><b>Dados Gerais: </b></legend>
<label for="CODIGO">
Código:<input type="text" name="CODIGO" id="CODIGO" MAXLENGTH="4" value="" onKeyUp="javascript:somente_numero(this);" required/>
</label>
<label for="NOME">
Nome:<input name="NOME" id="NOME" MAXLENGTH="50" value="" />
</label>
<label for="NOMEABR">
Nome Abreviado:<input name="NOMEABR" id="NOMEABR" MAXLENGTH="20" value="" />
</label>
<label for="GRUPO">
Grupo:
<?php
$rs = mysql_query("SELECT ID,DESCRICAO FROM FINANCEIRO.GRUPO ORDER BY ID");
montaCombo('GRP_cmb', $rs, 'ID', 'DESCRICAO',null);
?>
</label>
<label for="REPRES">
Representante:
<?php
$rs = mysql_query("SELECT CODIGO,ID FROM FINANCEIRO.REPRESENTANTE ORDER BY CODIGO");
montaCombo('REPRE_cmb', $rs, 'CODIGO', 'ID',null);
?>
</label>
<label for="TRANSP">
Transportadora:
<?php
$rs = mysql_query("SELECT CODIGO,NOME FROM FINANCEIRO.TRANSPORTADORA ORDER BY CODIGO");
montaCombo('TRANSP_cmb', $rs, 'CODIGO', 'NOME',null);
?>
</label>
<!--<label for="DATA">
Data Implant.:<input type="text" name="DATA" id="datepicker" MAXLENGTH="10" value="" />
</label>-->
</fieldset>
</div>
</div>
</body>
</html>
function montaCombo($nome, $rs, $valor, $descricao,$cmb)
{
echo("<select name='$nome' class='styled-select'>");
echo("<option selected='selected'></option>");
while ($obj = mysql_fetch_object($rs))
{
echo("t<option value='".$obj->$valor."' > ".$obj->$valor.":". $obj->$descricao." </option>");
}
if(!$cmb==null)
{
$row = mysql_fetch_array($cmb);
$a= $row[$valor];
$b=$row[$descricao];
echo ("<option value=\"$a\" selected>$a:$b</option></select>");
}else
{
echo ("</select>");
}
}