2
I’m using autocomplete from jQuery, but I’m having the following problem:
In the first line of <select>
I’d like the famous to appear "Escolha abaixo uma opção"
<option value="">Escolha abaixo uma opção</option>
Or, in the case of editing, value of the <select>
from the bank.
But nothing I do works, only a blank line appears.
Obs.: The autocoplete works normal. The <select>
normal population with data coming from the database. The problem is only the first line of the <select>
.
I created the script below that technically should fill the first line of <select>
.
$stringClientes = "";
if($Clientes == null) {
$stringClientes .= "<option value=''>Ainda não existe Cliente cadastrado</option>";
}
else {
$ClienteCadastro = $ClientesDao->pesquisaClienteEdicao($_GET["idClienteCadastro"]);
if(isset($_GET["idClienteCadastro"]) && $ClienteCadastro != null) {
$stringClientes .= "<option value='".$ClienteCadastro->getIdClientes()."'>".$ClienteCadastro->getNome()."</option>";
} else {
$stringClientes .= '<option value="">Escolha um cliente abaixo</option>';
}
foreach ($Clientes as $cliente) {
$stringClientes .= "<option value='".$cliente->getIdClientes()."'>".$cliente->getNome()."</option>";
}
}
And, in the <select>
<div>
<label>Cliente</label>
<select name="cliente" id="cliente" required>
<option value="" selected>Selecione</option>
<?php echo $stringClientes; ?>
</select><br /> <br />
</div>
In time. The variable, $stringClientes
, brings correctly to the <select>
all the <option>
s, including the first line. But it seems that autocomplete does not allow us to put text in the combobox.
The full return of select comes out like this:
<select name="cliente" id="cliente" required>
<option value="" selected>Selecione</option>
<option value='17'>José das couves</option>
<option value='14'>Fulano de Tal</option>
<option value='15'>tal fulano</option>
<option value='16'>Antônio Bandeiras</option>
<option value='17'>José das couves</option>
</select>
But the first line: <option value="" selected>Selecione</option>
doesn’t come out!
In that case I thought popular the type['text']
with the value ""
or what comes from the bank. How to fill this type['text']
that is only in the plugin?
Now I get it! Is that the autocomplete did not accept value="". I put value="#" and it worked!
– Carlos Rocha