<script type="text/javascript">
var baseurl = "http://www.codeagro.sp.gov.br/";
$( document ).ready(function(){
$('#programa').on('change', function()
{
var idprograma = $(this).val();
//alert(idprograma);
$.ajax({
type: 'post',
//url: baseurl + "edital/get_orgao_items",
url: baseurl + "acesso_usuarios/get_orgao_items",
data: {idprograma: idprograma},
dataType: 'json',
success: function (result)
{
$('#orgao').children().remove();
$.each(result, function(i, item)
{
$('#orgao').append("<option value='" + i + "'>" + item + "</option>");
});
},
error: function (result)
{
alert('Ocorreu algum erro.');
}
});
});
});
</script>
//EF 2015 Dez01 atualização do combo
public function get_orgao_items(){
$idprograma = $this->input->post('idprograma');
$orgao_items = $this->edital_model->get_orgao($idprograma);
echo json_encode($orgao_items);
}
function get_orgao($idprograma = 0)
{
$this->db->select('idorgao');
$this->db->select('nome');
$this->db->from('tb_orgao');
$this->db->where('idprograma', $idprograma);
// ------ Relevant line -------------------------
$this->db->order_by('nome ');
//----------------------------------------------------
$query = $this->db->get();
$result = $query->result();
// $sql = "SELECT idorgao, nome FROM tb_orgao WHERE idprograma =".$idprograma. " ORDER BY nome";
// $result = $this->db->query($sql);
//array to store idorgao & nome
$idorgao = array('-SELECT-');
$nome = array('-SELECT-');
for ($i = 0; $i < count($result); $i++)
{
array_push($idorgao, $result[$i]->idorgao);
array_push($nome, $result[$i]->nome);
}
return $department_result = array_combine($idorgao, $nome);
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE