Title: Problem with wp_dropdown_pages() (without Submit Button)
Last modified: August 21, 2016

---

# Problem with wp_dropdown_pages() (without Submit Button)

 *  [damienconnell](https://wordpress.org/support/users/damienconnell/)
 * (@damienconnell)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/problem-with-wp_dropdown_pages-without-submit-button/)
 * I have very nearly achieved what I want to do with wp_dropdown_pages().. namely
   have a drop down menu of certain child pages, with the user able to navigate 
   to each page by selecting them (ie, no submit button).
 * However, the problem I have is that the first page in the list is not active 
   as a link.. and it is always displayed as the first item in the list, no matter
   which page the user is on.
 * Here’s my code (taken from online examples, I am new to JS)
 *     ```
       <div class="menu">
       <?php wp_dropdown_pages($args = array('child_of'=>38)); ?>
       <script type='text/javascript'>
       /* <![CDATA[ */
         var dropdown = document.getElementById("page_id");
         function onPageChange() {
           if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
             location.href = "<?php echo home_url(); ?>/?page_id="+dropdown.options[dropdown.selectedIndex].value;
           }
         }
         dropdown.onchange = onPageChange;
   
       </script>
       </div>
       ```
   
 * I would like to either
 * A) Have all the page links work and the list display the current page that the
   user is on (preferred)
 * or B) Have the default display something like “Select Page”, and have all the
   drop down page links work.

The topic ‘Problem with wp_dropdown_pages() (without Submit Button)’ is closed to
new replies.

## Tags

 * [down](https://wordpress.org/support/topic-tag/down/)
 * [pages](https://wordpress.org/support/topic-tag/pages/)
 * [wp_dropdown_pages](https://wordpress.org/support/topic-tag/wp_dropdown_pages/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [damienconnell](https://wordpress.org/support/users/damienconnell/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/problem-with-wp_dropdown_pages-without-submit-button/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
