How to set onchange of two dropdown in JQuery & CodeIgniter-Collection of common programming errors
I’m using CodeIgniter and I have a question in setting onchange on two dropdown using JQuery, here is the code :
And this is the javascript:
$(function() {
// navigate to page on click event
$('#actype').bind('change', function() { goToPage(); } );
$('#acreg').bind('change', function() { goToPage(); } );
});
function goToPage() {
location.href = 'http://localhost/CAMP/CI/index.php/blog/show_package/'+$("#actype :selected").val()+'/'+$("#acreg :selected").val();
}
So when the first dropdown is selected, the page will add some uri segment. And based on that segment, some query will run and then list of second dropdown is generated.
The problem is when the second dropdown is selected, the page adds “undefined” as new segment. I think the page cannot fetch the selected value of second dropdown.
Please Help.