html input box..... remove value with javascript

Discussion in 'Programming' started by HolyMan, Mar 1, 2005.

  1. #1
    Hi All,

    I'm not sure if this can be done, but I have an input box (as part of a search form) that looks like this:
    <INPUT size=18 value="Search coming soon" name=query>
    Code (markup):
    What I want to do is have the value="Search coming soon" dissapear when a browser clicks into the box.

    Any help??????
     
    HolyMan, Mar 1, 2005 IP
  2. nullbit

    nullbit Peon

    Messages:
    489
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <input size="18" value="Search coming soon" id="query" name="query" 
    onclick="this.value = ''" />
    
    Code (markup):
    I don't code JS, this might not be the best way to do it, but it works!
     
    nullbit, Mar 1, 2005 IP
  3. HolyMan

    HolyMan Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    excellent nullbit......

    Worked like a dream....

    Thanks
     
    HolyMan, Mar 2, 2005 IP
  4. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    but let say if you already typed something the text field, and you reclick at it, the value will be erased too isn't it?
    maybe there are a better solution than this;
     
    fairuz.ismail, Jan 29, 2008 IP