• Instead of having a submit button at all, how would this be done with the onChange event?

    Basically, I’d like to select an author from the dropdown list and have it directly link to the corresponding author page, rather than clicking on a submit button.

    Here is the markup I have with a submit button:

    <form action="<?php bloginfo('url'); ?>" method="get">
    <?php wp_dropdown_users(array('name' => 'author')); ?>
    <input type="submit" name="submit" value="view" />
    </form>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter polyfade

    (@polyfade)

    There’s probably a more efficient way of displaying the onChange event for users. This is what I came up with:

    <?php
    $args = array('selected' => 'false', 'name' => 'author', 'who' => 'authors', 'include' => '14,15,16');
    $blogusers = get_users($args);
    ?>
    
    <form action="<?php bloginfo('url'); ?>" method="get">
    <select id="select-of-tags" name="author" onchange="if(this.selectedIndex){location.href=(this.options[selectedIndex].value)}">
    <option value="">View Authors…</option>
    <?php foreach ($blogusers as $user) {?>
    <option value="<?php bloginfo('url'); ?>/author/<?php echo $user->user_login ?>"><?php echo $user->display_name ?></option>
    <?php } ?>
    </select>
    </form>

    Anyone have a better solution?

    No, but thanks for posting yours, was just about to do the same till I found your post.

    Seems weird tto me that wp_get_archives() doesn’t include type options for authors/cats/tags etc.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using onChange event with wp_dropdown_users’ is closed to new replies.