WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Initial Text in Search Box? (3 posts)

  1. aptdesignonline
    Member
    Posted 4 years ago #

    Hi,

    I'm trying to insert a search box in my header. I've done that with get_search_box
    (http://codex.wordpress.org/Function_Reference/get_search_form)

    What I would like to now do is have there be initial text in that form that says "Search" that when clicked on goes away and you can type in your own search query.

    Is this possible to do with the WP get_search_box? Or, any other suggestions for how to do this?

    Thanks!

  2. This is what I use:

    <form id="searchform" method="get" action="<?php bloginfo('url'); ?>/"><input type="text" value="Search this site" onblur="if(this.value == '') {this.value = 'Search this site';}" onfocus="if(this.value == 'Search this site') {this.value = '';}" name="s" id="s" size="25" />
    
    <input type="submit" id="searchsubmit" value="Search" class="submit" name="searchsubmit"/></form>

    Style the text if you want:

    #searchform, input#s
    {
    color:#000;
    font-size: 1em;
    font-style: italic;
    }
  3. assipattle
    Member
    Posted 4 years ago #

    I have the following code on my search and wanted to achieve the same thing but somehow when I use the info above it does not working for me. I there something I miss?
    <form method="get" id="searchform" action="" >
    <div>
    <input type="text" value="" />
    <input type="submit" id="searchsubmit" value="" />
    </div>
    </form>

Topic Closed

This topic has been closed to new replies.

About this Topic