1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Javascript Search Box Help

Discussion in 'JavaScript and AJAX' started by Talks_44, Sep 19, 2007.

  1. Talks_44

    Talks_44 New Member

    Joined:
    Sep 19, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Hi Guys,

    i spoke to ben about this before, and i thought i would try and have a go at it myself.

    but as i do not know the first thing about javascript and not being able to find anything on the internet i thought i would ask here.

    i currently have a product search box on my shop which is made up of the following HTML.

    CODE


    Code:
    <h3>Product Search</h3>
    <p></p>
    <form action="index.asp?function=SEARCH" method="post">
    <input name="search" type="text" value="Type Search Criteria + Enter" size="25" class="searchbox" />
    </form>
    <p></p>
    
    as you can see i have it so that in the contents of the search box it says "Type Search Criteria + Enter" but the problem is the user has to delete all whats in the box before they type anything in

    what i would like to happen is that when someone clicks in the search box it automaticly deletes "Type Search Criteria + Enter" allowing them to enter a product without having to delete anything.

    also how hard is it to get the background colour of the search box to change?

    Thanks in advance
     
    Last edited by a moderator: Sep 20, 2007
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Add an onfocus handler, on the search box!

    HTML:
    <h3>Product Search</h3>
    <p></p>
    <form action="index.asp?function=SEARCH" method="post">
    <input name="search" type="text" value="Type Search Criteria + Enter" size="25" onFocus='this.value="";' class="searchbox" />
    </form>
    <p></p>
    
     
  3. Talks_44

    Talks_44 New Member

    Joined:
    Sep 19, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Thx mate...!!!
     

Share This Page