1
Hi, I had already received a great help when I needed a select field to be filled automatically, in this post here: Fill select javascript / jquery field
is working perfectly mind, but now I need that when opening a page where the select field is already filled, the second select field fills automatically too, but it is only filling in the moment I click and select something in my first select field.
Here is the javascript code that fills the select (I need it to fill in when I open the page, and a "Selected" value will come from the database, and not just when I select something)
$(document).ready(function() {
$('#cSecretaria').on('change', function(){
$.post('http://siscpd.com/_require/_jp/jpcarregasetor.php',
{
id_sec: document.getElementById("cSecretaria").value,
},
function (res) {
$('#cSetor').html(res).selectpicker('refresh');
}
)
})
})