wizard
August 25, 2004, 9:10pm
1
Let me get right to the point – You’ve seen those Input Text Fields on web sites that have titles on them, i.e. Name, Email, Message, in the Text field itself.
Then, when you click on the the text field to type something in, the “title” disappears and you can type your info in.
Perfect example: KurtNoble.com (Under “contact”)
How do I do this?
system
August 25, 2004, 10:14pm
2
AS Panel>Objects>Movie>Text Field>Methods>onSetFocus
go play
Prophet.
system
August 25, 2004, 10:38pm
3
Very close… it was: AS Panel>Objects>Movie>Text Field>Events >onSetFocus
Even so, that wasn’t much help to me… how about an explanation, or the ActionScript itself? :beam:
Thanks anyway.
system
August 26, 2004, 1:07am
4
you can test this:
input.onSetFocus=function(){
input.text=" ";
}
“input” is your textfield name.
system
August 26, 2004, 2:09am
5
Hey egoldy, I tried that earlier today and it does work. However, the thing I don’t like is that if you click on it a second time (once you’ve already typed something in it), it also erases that… and I don’t want people’s info being erased.
system
August 26, 2004, 3:31am
6
wizard:
Hey egoldy, I tried that earlier today and it does work. However, the thing I don’t like is that if you click on it a second time (once you’ve already typed something in it), it also erases that… and I don’t want people’s info being erased.
please check out my attachment files.
oh!.cannot upload?
http://www.bggt.com.cn/ego/design/test1.swf
fla:
http://www.bggt.com.cn/ego/design/emailtest1.rar
system
August 26, 2004, 3:38am
7
Okay, attach them and I’ll take a look at em’ .
Edit: Oh there they are.
system
August 26, 2004, 3:42am
9
Okay, that’s what I want, any chance you can post the .fla?
I’m not sure what the .rar file is for… if you can’t upload the .fla you could also email it to me at: forumwizard[at]yahoo.com
Thanks :thumb:
system
August 26, 2004, 7:02am
12
add this AS into your first frame:
function focusToggle(name) {
if (this[name].text != “”) {
if (this[“tempStr_”+name] == null) {
this[“tempStr_”+name] = this[name].text;
trace(this[“tempStr_”+name]);
}
if (this[name].text == this[“tempStr_”+name]) {
this[name].text = “”;
}
} else {
this[name].text = this[“tempStr_”+name];
}
}
a.tabIndex = 1;
b.tabIndex = 2;
c.tabIndex = 3;
d.tabIndex = 4;
a.onSetFocus = function() {
focusToggle(“a”);
};
a.onKillFocus = function() {
focusToggle(“a”);
};
b.onSetFocus = function() {
focusToggle(“b”);
};
b.onKillFocus = function() {
focusToggle(“b”);
};
c.onKillFocus = function() {
focusToggle(“c”);
};
c.onSetFocus = function() {
focusToggle(“c”);
};
d.onSetFocus = function() {
focusToggle(“d”);
};
d.onKillFocus = function() {
focusToggle(“d”);
};
a,b,c,d, is instanceName of the inputTextField.
system
August 26, 2004, 8:49am
13
If you want to make every thing from scratch add this to your first frame:
//tab index of input text fields
name_str.tabIndex = 1;
company_str.tabIndex = 2;
email_str.tabIndex = 3;
subject_str.tabIndex = 4;
message_str.tabIndex = 5;
//input text field lables
name_str.text = “Name”;
company_str.text = “Company”;
email_str.text = “Email”;
subject_str.text = “Subject”;
message_str.text = “Message”;
//clear input text field onFocus, if something typed in don’t clear input text field, if nothing typed in rename input text field onFocusKill
name_str.onSetFocus = function() {
if (name_str.text == “Name”) {
name_str.text = “”;
}
};
name_str.onKillFocus = function() {
if (name_str.text == “”) {
name_str.text = “Name”;
}
};
company_str.onSetFocus = function() {
if (company_str.text == “Company”) {
company_str.text = “”;
}
};
company_str.onKillFocus = function() {
if (company_str.text == “”) {
company_str.text = “Company”;
}
};
email_str.onSetFocus = function() {
if (email_str.text == “Email”) {
email_str.text = “”;
}
};
email_str.onKillFocus = function() {
if (email_str.text == “”) {
email_str.text = “Email”;
}
};
subject_str.onSetFocus = function() {
if (subject_str.text == “Subject”) {
subject_str.text = “”;
}
};
subject_str.onKillFocus = function() {
if (subject_str.text == “”) {
subject_str.text = “Subject”;
}
};
message_str.onSetFocus = function() {
if (message_str.text == “Message”) {
message_str.text = “”;
}
};
message_str.onKillFocus = function() {
if (message_str.text == “”) {
message_str.text = “Message”;
}
};
name_str, company_str, email_str, subject_str, message_str, is the intance names of the input text fields
system
August 26, 2004, 5:32pm
14
holy jeezus… no, i didnt read all of the above… just thought id tell wizard to put an IF statement before he changes the value of his text box to nothing to see if its current value is equal to its default:
input.onSetFocus=function(){
if(input.text == "This was the text you had in here before users put their input in"){
input.text=""
}
}
Prophet.
system
August 26, 2004, 6:22pm
15
headznet that worked perfectly… thank you very much :} .
And thanks to everyone else for your inputs as well, thank you.