WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can you remove search form's button? (4 posts)

  1. novice21
    Member
    Posted 6 years ago #

    I would like to change the search form so that there is no button but I can't make it work right.

    Basically I want my search form to be a text box where users would type something and then press enter to activate the search. How would I change the code to do this? Is that even possible?

    <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
    <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />
    </form>

    Thank you.

  2. intricateartist
    Member
    Posted 6 years ago #

    It goes into your sidebar (or wherever) like this:

    <?php include (TEMPLATEPATH . '/searchform.php'); ?>

    and your searchform.php looks like this:

    <form method="get" id="search_form" action="<?php bloginfo('home'); ?>" />
    	<input name="s" type="text" class="search_input" id="s" onfocus="if (this.value == 'type keywords & hit enter') {this.value = '';}" onblur="if (this.value == '') {this.value = 'type keywords & hit enter';}" value="type keywords & hit enter" />
    	<input type="hidden" id="searchsubmit" value="Search" />
  3. novice21
    Member
    Posted 6 years ago #

    Thanks a bunch intricateratist! This works just fine!

    I only had to remove the & because my page wouldn't validate, I changed instances of 'type keywords & hit enter' to 'Search My Blog'

    I'm wondering if you know the answer to this, do you have any idea how to get the search page to return searches with 'you have searched for ' [insert keywords] followed by the search results?

    Thanks again! I really appreciate your help

  4. Dgold
    Member
    Posted 6 years ago #

    novice21, the Search Results Count plugin will do just that for you.

    Showing 4 results for the search terms:  plate.

    http://www.village-idiot.org/archives/2007/05/26/search-results-count-plugin/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags