# Whats the code to focus on a textbox?

**URL:** <https://forum.kirupa.com/t/whats-the-code-to-focus-on-a-textbox/182489>\
**Category:** flash\
**Created:** [March 18, 2006, 8:12pm UTC](https://forum.kirupa.com/t/whats-the-code-to-focus-on-a-textbox/182489 "2006-03-18T20:12:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![REEF](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@REEF](https://forum.kirupa.com/u/REEF)\
**Post date:** [March 18, 2006, 8:12pm UTC](https://forum.kirupa.com/t/whats-the-code-to-focus-on-a-textbox/182489/1 "2006-03-18T20:12:54Z")

</div>

I’ve been wondering, if an input box with a variable of name and is inside an MC with instance name of contact\_form, what the code I can put on a frame so that as the frame loads, the focus of the blinker is automatically set onto that input?

Ive used this:

selection.setFocus(“contact\_form.name”);

And it’s completely not working. I traced selection.getFocus(); and it returns as undefined…

Any clues? Thanks.

---

<div class="post-metadata">

**Author:** ![KyoKusanagi](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@KyoKusanagi](https://forum.kirupa.com/u/KyoKusanagi)\
**Post date:** [March 19, 2006, 3:56am UTC](https://forum.kirupa.com/t/whats-the-code-to-focus-on-a-textbox/182489/2 "2006-03-19T03:56:25Z")

</div>

```auto
myMovieClip.contact_form.setFocus();

```

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [March 19, 2006, 4:12am UTC](https://forum.kirupa.com/t/whats-the-code-to-focus-on-a-textbox/182489/3 "2006-03-19T04:12:04Z")

</div>

Two problems:  
[LIST=1]  
[_]Selection should be capitalized.  
[_]Don’t use a string for the parameter.[/LIST]

```auto
Selection.setFocus(contact_form.name);

```

:hoser:

---

<div class="post-metadata">

**Author:** ![REEF](https://avatars.discourse-cdn.com/v4/letter/r/ce73a5/32.png) [@REEF](https://forum.kirupa.com/u/REEF)\
**Post date:** [March 19, 2006, 5:06am UTC](https://forum.kirupa.com/t/whats-the-code-to-focus-on-a-textbox/182489/4 "2006-03-19T05:06:51Z")

</div>

Kyo, i’m not sure how your code sets the focus on the input box inside the MC. I actually figured it out. It needs to target the **instance name of the text box** not the variable of it - lol -.

Sorry for the waste of time.

---

<div class="post-metadata">

**Author:** ![KyoKusanagi](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@KyoKusanagi](https://forum.kirupa.com/u/KyoKusanagi)\
**Post date:** [March 19, 2006, 7:51am UTC](https://forum.kirupa.com/t/whats-the-code-to-focus-on-a-textbox/182489/5 "2006-03-19T07:51:02Z")

</div>

yes, that’s what i mean.
