• Resolved xinfo

    (@xinfo)


    currently my search function work well

    Problem :when a user want to search and he click on the keyword field

    standard Search eg books always appear user have to

    manually delete(back space) those Search eg books and

    have to type the keyword .

    what i am looking for, if a user place the mouse in keyword area Search eg books should disappear and keyword should be shown in search box in search page after submit, when user mouse back or return to any page search field should show again Search eg books

    i tired using onfoucs but i think my code is wrong can you guys help me out

    my code

    <?php if(is_search()) { the_search_query(); } else { ?>Search eg books<?php } ?>

Viewing 6 replies - 1 through 6 (of 6 total)
  • This is what I use for onfocus and onblur in a search box:

    <form id="searchform" method="get" action="<?php bloginfo('siteurl')?>/index.php"><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="45" />&nbsp;<input type="submit" value="Search" class="submit" name="searchsubmit"/></form>

    Change the size to what you need, and with CSS you can style the text in the box, too.

    #searchform, input#s
    {
    color:#000;
    font-size: 1em;
    font-style: italic;
    }

    i would like to have a template like http://www.skysiptel.com do any one know where i can get one like this one

    Thread Starter xinfo

    (@xinfo)

    @songdogtech
    you code work well wat i looked for but it don’t show me searched keyword in search box in search page .

    i need more like
    after user submit the keyword it redirect to search page with list of result and seach box should show the search query, any tweak ?

    @wissam661

    you can post relevant question or answer for this topic don’t post irrelevant question else you can open new topic

    I use Results Count (not the other pluging Results Count Remix) to show the number of search results and the search term:

    http://wordpress.org/extend/plugins/results-count/

    I don’t know how to repopulate the search box with the search term; might be confusing. You can always put the search box code in search.php, so it shows up in results page so people can search again.

    @xinfo

    Use a modified version of songdogtech’s script:

    <form id="searchform" method="get" action="<?php bloginfo('siteurl')?>/index.php">
    <input type="text"
           value="<?php if($_GET['s']) {echo $_GET['s'];} else {echo 'Search this site';} ?>"
           onfocus="if(this.value=='Search this site'<?php if($_GET['s']) echo ' || this.value == \'' . $_GET['s'] . '\''; ?>) {this.value = '';}"
           onblur="if(this.value == '') {this.value = '<?php if($_GET['s']) {echo $_GET['s'];} else {echo 'Search this site';} ?>';}"
           name="s"
           id="s"
           size="45" />
    <input type="submit" value="Search" class="submit" name="searchsubmit"/>
    </form>

    This will populate a new search box with “Search this site” and use the appropriate JavaScript onfocus and onblur functions to clear it when the user wants to enter something. If you’re on a search results page, though, it will populate the search box with whatever the search term was.

    Thread Starter xinfo

    (@xinfo)

    @ ericmann

    this is the hack i am looking so for it’s working great, thank you so much for spending time for me, more over you under stand my English lol
    English is not my first language …

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Need help for search box tweaking’ is closed to new replies.