function clienteChange() {
function clienteChange() {
var id = $('#idCliente').val();
$.ajax(
{
url:"/Entregas/clientes.endereco.php?id=" + id,
dataType : 'json',
success:function(result) {
$('[name="cham_endereco[]"]').val(result.endereco);
$('[name="cham_numero[]"]').val(result.numero);
$('[name="cham_bairro[]"]').val(result.bairro);
$('[name="cham_cidade[]"]').val(result.cidade);
}
});
}
}
Para buscar os resultados, fiz o clientes.endereco.php desta forma:
$result['endereco'] = "teste"; die(json_enconde($result));
$result['endereco'] = "teste";
die(json_enconde($result));
<tbody id="servicosTable" style="width: 898px;">
<tr id="servico_0">
<td style="line-height: 10px !important;">
<select class="input-small" name="cham_tiposervico[]">
<option value="0" selected >Coleta</option>
<option value="1" >Entrega</option>
<option value="2" >Retorno</option>
</select>
</td>
<td style="line-height: 10px !important; font-size: 12px !important;">
<input class="input-small" style="width: 222px !important;" type="text" name="cham_endereco[]" value="">
</td>
<td style="line-height: 10px !important; font-size: 12px !important;">
<input class="input-small" style="width: 50px !important;" type="text" name="cham_numero[]" value="">
</td>
<td style="line-height: 10px !important; font-size: 12px !important;">
<select class="input-small selectCidade" name="cham_cidade[]" id="cham_cidade[]" style="width: 140px;">
<option value="0">Selecione</option>
<? foreach($this->data['listaCidade'] as $cidade){ ?>
<option value="<? echo $cidade->idCidade; ?>"><? echo $cidade->cidade; ?></option>
<? } ?>
</select>
</td>
<td style="line-height: 15px !important; font-size: 12px !important;"> <select class="input-small selectBairro" name="cham_bairro[]" id="cham_bairro[]" style="width: 120px;">
<option value="">Selecione</option>
</select>
</td>
<td style="line-height: 15px !important; font-size: 12px !important;">
<input class="input-small" type="text" name="cham_falarcom[]" value="">
</td>
<td>
<button class="btn" type="button" onclick="removerServico(0)" style="padding: 3px; width: 32px !important;"><i class="icon-trash"></i></button>
</td>
</tr>
</tbody>
Formulário: -> select class="input-xxlarge" style="width: 409px !important;" id="idCliente" name="idCliente" onchange="clienteChange()"
select class="input-xxlarge" style="width: 409px !important;" id="idCliente" name="idCliente" onchange="clienteChange()"