Results 1 to 5 of 5

Thread: Input text fields: Initial values

  1. #1

    Input text fields: Initial values

    Hi there,

    I am creating a flash user input form and want to have some initial values in each Input text field (i.e. - 'First Name', 'Email Address' etc).

    I know I can simply type these values into the Input text fields in the .fla movie, but doing this means the user has to delete the initial value before entering their own details.

    Which leads me to to my question:

    How do I make the initial values automatically disappear when the user clicks their mouse on the Input text fields?

    Thank you in advance,
    the chad

  2. #2
    Digitalosophy
    n/a
    posts
    Guest
    do a search of setFocus

  3. #3
    I dont know if its possible with flash5, but heres a MX version...
    Code:
    fields = [name, age, country];//your textfields instance names
    captions = ["Your Name", "Your Age", "Your country"];//default text for each textfield
    for (var i in fields) {
    	this.fields[i].j = this.i;
    	this.fields[i].text = captions[i];
    	this.fields[i].onSetFocus = function() {
    		if (this.text == captions[this.j]) {
    			this.text = "";
    		}
    	};
    	this.fields[i].onKillFocus = function() {
    		if (!this.length) {
    			this.text = captions[this.j];
    		}
    	};
    }

  4. #4
    Digitalosophy
    n/a
    posts
    Guest
    once again, that's a nice chunk of code claudio. i did something similair but this will save me a lot of time for the next time i need to do this.

    btw this should work for flash 5

    edit: can you please explain onKillFocus?

  5. #5
    Welcome Digitalosophy
    I dont think this will work in flash5, since textfields instance names is MX feature.
    textfield.onKillFocus is triggered when the textfield loses focus.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012