SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Splints's Avatar
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face Input text box properties

    In Flash MX

    I have a mailing form.

    It consists of a bunch of input fields where it grabs info on the client.

    Is there a way I can have text in the input text box, but as soon as the user clicks inside it, it highlights the text and as soon as they type clears the text that was there and it replaces it with what they are typing.

    e.g:

    A date input text field where it wants the user to enter the date.
    The field must display like this when the page loads

    dd/mm/yy

    But once they click in that text field it selects all of the text that is in there. the "dd/mm/yy" and replaces it with whatever they are typing.

    I would appreciate some help

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is how I do it, this should work for all the text fields you have because it can detect the current field in focus.

    Code:
    myLstnr = {};
    myLstnr.onChanged = function() {
     clearInterval(myInterval);
    }
    function resetInterval() {
     myInterval = setInterval(checkSel, 10); 
    }
    function checkSel() {
     if(Selection.getFocus() != null) {
      curFocus = eval(Selection.getFocus());
      curFocus.addListener(myLstnr);
      curFocus.onKillFocus = resetInterval;
      Selection.setSelection(0,curFocus.text.length);
     }
    }
    resetInterval();


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
  •