#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    15
    Rep Power
    0

    How to make an input box clear when clicked


    I have a search input box with the initial text of “Search Products”.

    I’d like this text to disappear when the user clicks the box so he is set to enter his search.

    I tried the approach with a movie clip and an invisible button on the initial fame. When the user clicks the box it clears the text variable but he has to click one more time on the text box to get a cursor.

    Is there a one-click approach that will clear the text and have the cursor ready to go?

    See what I did so far at:

    http://www.tdipower.com/2002

    Thanks
  2. #2
  3. No Profile Picture
    Polynesian Monkey God
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    Monkeytown, USA
    Posts
    57
    Rep Power
    13
    You could make the textbox a movieclip and then create an onClipEvent hit test routine that checks to see if the mouse is inside the textbox's movieclip when the mouse button is clicked (and clear the textbox if it is).

    But there ought to be an easier way.
    "We're all - monkeys!" -- Jeffrey Goines, 12 Monkeys
  4. #3
  5. No Profile Picture
    Shrill Digital God
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Location
    Raleigh, NC
    Posts
    64
    Rep Power
    14
    Maybe put a button underneath the text box. If the text box has a variable name, telling the button to make that variable = " " should do it.

    on (release, mouseover) {
    textVarName = " ";
    }
    I'm not impatient, I just have a low tolerance for boredom.
  6. #4
  7. No Profile Picture
    Polynesian Monkey God
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Location
    Monkeytown, USA
    Posts
    57
    Rep Power
    13
    If that's the way to go, just make sure that you include :
    Code:
    on (release, mouseover) { 
      if (textVarName ne "") {
        textVarName = " "; 
      }
    }
    ...or something else to keep from clearing the textbox every time it's clicked on, unless that's what you want.
    "We're all - monkeys!" -- Jeffrey Goines, 12 Monkeys

IMN logo majestic logo threadwatch logo seochat tools logo