{"id":6739,"date":"2014-04-23T02:02:46","date_gmt":"2014-04-23T02:02:46","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/how-to-set-onchange-of-two-dropdown-in-jquery-codeigniter-collection-of-common-programming-errors\/"},"modified":"2014-04-23T02:02:46","modified_gmt":"2014-04-23T02:02:46","slug":"how-to-set-onchange-of-two-dropdown-in-jquery-codeigniter-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/how-to-set-onchange-of-two-dropdown-in-jquery-codeigniter-collection-of-common-programming-errors\/","title":{"rendered":"How to set onchange of two dropdown in JQuery &amp; CodeIgniter-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m using CodeIgniter and I have a question in setting onchange on two dropdown using JQuery, here is the code :<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>And this is the javascript:<\/p>\n<pre><code>      \n$(function() {           \n\/\/ navigate to page on click event           \n$('#actype').bind('change', function() { goToPage(); } );      \n$('#acreg').bind('change', function() { goToPage(); } );      \n});       \n\nfunction goToPage() {\nlocation.href = 'http:\/\/localhost\/CAMP\/CI\/index.php\/blog\/show_package\/'+$(\"#actype :selected\").val()+'\/'+$(\"#acreg :selected\").val();\n} \n \n<\/code><\/pre>\n<p>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.<\/p>\n<p>The problem is when the second dropdown is selected, the page adds &#8220;undefined&#8221; as new segment. I think the page cannot fetch the selected value of second dropdown.<\/p>\n<p>Please Help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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 $(&#8216;#actype&#8217;).bind(&#8216;change&#8217;, function() { goToPage(); } ); $(&#8216;#acreg&#8217;).bind(&#8216;change&#8217;, function() { goToPage(); } ); }); function goToPage() { location.href = &#8216;http:\/\/localhost\/CAMP\/CI\/index.php\/blog\/show_package\/&#8217;+$(&#8220;#actype :selected&#8221;).val()+&#8217;\/&#8217;+$(&#8220;#acreg [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6739","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6739","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6739"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6739\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}