SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2010
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    filling search query box with text that disappears when clicked on

    I have a basic search box that I want filled with light gray text that says <enter search query> or similar, and I want it to disappear when the box is clicked on. I also want the '<enter search query>' to reappear when the page is reloaded.

    Any tips, URLs, etc. with info are appreciated.

    Thx.

  2. #2
    SitePoint Member
    Join Date
    Jun 2010
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Figured it out. Pretty simple.

    <input type="text" name="query" size="16" maxlength="40" value=" <enter query>" class="search_box" onFocus=this.value=''>

  3. #3
    SitePoint Member
    Join Date
    Jun 2010
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm, another prob though. If someone simply clicks on the search button, the query ends up being <enter query>.

  4. #4
    SitePoint Member
    Join Date
    Jun 2010
    Location
    Canada
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Think I figured this one out also. Instead of javascript changes on the pages where the search box is, I added the below to the backend Perl search script.

    $query =~ s/ \<enter query\>//g;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •