javascript - value is not selected in dropdown and please convert Inline js code to external j query -


hello can convert inline js code external js code how possible tried not possible.and value not selected in dropdownlist how possible ? code hear

<select class="form-control" id="ncats" name="ncats" onchange="this.options[this.selectedindex].value && (window.location = this.options[this.selectedindex].value);">     <option value="/pr192/index.php?id=10">all</option>     <option value="/pr192/index.php?id=25">electric</option>     <option value="/pr192/index.php?id=15">solar</option>     <option value="/pr192/index.php?id=19">real estate</option></select> 

convert inline function

<script>     function fred(sel) {         sel.options[sel.selectedindex].value && (window.location = sel.options[sel.selectedindex].value);     } </script> 

then call function, passing this argument

<select class="form-control" id="ncats" name="ncats" onchange="fred(this);">     <option value="/pr192/index.php?id=10">all</option>     <option value="/pr192/index.php?id=25">electric</option>     <option value="/pr192/index.php?id=15">solar</option>     <option value="/pr192/index.php?id=19">real estate</option></select> 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -