• why my code not work?

    <?php print wpbusdirman_post_list_categories(); ?>
    		<script type="text/javascript">
        var dropdown = document.getElementById("cat");
        function onCatChange() {
    		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    
    			location.href = "<?php get_category_link('cat=?>"+dropdown.options[dropdown.selectedIndex].value+"<?php ') ?>";
    		}
        }
        dropdown.onchange = onCatChange;
    	</script>
    		</div>

    that codes generates a select box

    <<select name="cat" id="cat" class="postform">
    	<option class="level-0" value="14736">Jakarta Selatan&nbsp;&nbsp;(1)</option>
    	<option class="level-0" value="14737">Jakarta Timur&nbsp;&nbsp;(1)</option>
    	<option class="level-0" value="14726">Jakarta Utara&nbsp;&nbsp;(1)</option>
    </select>

    can anyone help me?? i want to use wp dropdown category without using submit button

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dammion

    (@dammion)

    i’m sorry.. this is the script..

    <?php print wpbusdirman_post_list_categories(); ?>
    <script type=”text/javascript”>
    var dropdown = document.getElementById(“cat”);
    function onCatChange() {
    if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {

    location.href = “<?php get_category_link(‘cat=?>”+dropdown.options[dropdown.selectedIndex].value+”<?php ‘) ?>”;
    }
    }
    dropdown.onchange = onCatChange;
    </script>

    Thread Starter dammion

    (@dammion)

    i’m really sorry.. this is the real code.. please anybody help me..

    <?php print wpbusdirman_post_list_categories(); ?>
    		<script type="text/javascript">
        var dropdown = document.getElementById("cat");
        function onCatChange() {
    		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    
    			location.href = "<?php get_category_link('cat="+dropdown.options[dropdown.selectedIndex].value+" ') ?>";
    		}
        }
        dropdown.onchange = onCatChange;
    	</script>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘My code not work’ is closed to new replies.