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

  1. aptdesignonline
    Posted 6 years ago #


    I'm trying to insert a search box in my header. I've done that with get_search_box

    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?


  2. Mark Ratledge
    Forum Moderator
    Posted 6 years ago #

    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
    font-size: 1em;
    font-style: italic;
  3. assipattle
    Posted 6 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="" >
    <input type="text" value="" />
    <input type="submit" id="searchsubmit" value="" />

Topic Closed

This topic has been closed to new replies.

About this Topic