# Request focus help

**URL:** <https://forum.servoy.com/t/request-focus-help/1184>\
**Category:** Classic Servoy\
**Created:** [February 4, 2004, 12:02pm UTC](https://forum.servoy.com/t/request-focus-help/1184 "2004-02-04T12:02:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [February 4, 2004, 12:02pm UTC](https://forum.servoy.com/t/request-focus-help/1184/1 "2004-02-04T12:02:33Z")

</div>

I have a method that executes when the company\_text field is changed. I need to confirm that company name has been entered before company\_text (a checkbox) is changed from empty to filled. All of the method works as expected except that the requestFocus just doesn’t happen!

If I run the requestFocus on its own it works fine, but at the the end of this method - nothing!

controller.saveData();  
if ( company\_text == ‘company’ && company\_name ==‘’||company\_text == ‘company’ && company\_name == null)  
{  
plugins.dialogs.showErrorDialog( “Missing data”, “Please enter company name first!”, ‘OK’);  
company\_text = null;  
forms.contacts\_card.elements.company\_name.requestFocus();  
}

does anyone know why the requestFocus is not working?

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [February 4, 2004, 9:07pm UTC](https://forum.servoy.com/t/request-focus-help/1184/2 "2004-02-04T21:07:12Z")

</div>

to test: if you remove the controller.saveData call does it work then?

If still not, then can you give me a small example?

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 4, 2004, 11:34pm UTC](https://forum.servoy.com/t/request-focus-help/1184/3 "2004-02-04T23:34:16Z")

</div>

Hai Drookwood, I noticed that you do the requestfocus with a form name attached. Does that mean this method is outside this form (on another form)?

BTW why don’t you do:

```auto
if (company_text == 'company' && !company_name) 

```

Ciao

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [February 9, 2004, 10:07pm UTC](https://forum.servoy.com/t/request-focus-help/1184/4 "2004-02-09T22:07:03Z")

</div>

> jcompagner:  
> to test: if you remove the controller.saveData call does it work then?

I have tried this now:

if(company\_text == ‘company’ && !company\_name)  
{  
plugins.dialogs.showErrorDialog(“Missing data”", “Please enter company name first!”, “OK”);  
company\_text = ‘’;  
elements.company\_name.requestFocus();

Result is the same as before: everything else works but focus is not gained on the company\_name field

> If still not, then can you give me a small example?

I’ll see if can set up a small test file and send it!

---

<div class="post-metadata">

**Author:** ![drookwood](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@drookwood](https://forum.servoy.com/u/drookwood)\
**Post date:** [February 9, 2004, 10:09pm UTC](https://forum.servoy.com/t/request-focus-help/1184/5 "2004-02-09T22:09:59Z")

</div>

> IT2BE:  
> Hai Drookwood, I noticed that you do the requestfocus with a form name attached. Does that mean this method is outside this form (on another form)?

No, the method is on the form, but removing the formname also makes no difference!

> BTW why don’t you do:
> 
> ```auto
> if (company_text == 'company' && !company_name) 
> 
> ```

Thanks - much more elegant!

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [February 10, 2004, 7:13am UTC](https://forum.servoy.com/t/request-focus-help/1184/6 "2004-02-10T07:13:46Z")

</div>

Thanks for the compliment but it doesn’t help solving the thing unfortunately ![:?]( "Confused")

I don’t have any answers/questions anymore… A bug?

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [March 26, 2004, 11:12pm UTC](https://forum.servoy.com/t/request-focus-help/1184/7 "2004-03-26T23:12:03Z")

</div>

I’m having a similar situation. All I want to do is create a new record and have a field get the focus.

```auto
controller.newRecord();
elements.field.requestFocus();

```

If I only use the requestFocus it works fine. I’m running RC9 under MacOS 10.3.3.

Am I doing something wrong?

Ronnie

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [March 27, 2004, 10:46am UTC](https://forum.servoy.com/t/request-focus-help/1184/8 "2004-03-27T10:46:16Z")

</div>

what view are you in?  
List/Table or record?

for list/table you have to have RC10..

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [March 27, 2004, 1:22pm UTC](https://forum.servoy.com/t/request-focus-help/1184/9 "2004-03-27T13:22:53Z")

</div>

There you have it, it’s a list view. Is RC10 available? because Servoy can’t find any updates.

Thanks,

Ronnie

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [March 28, 2004, 1:49am UTC](https://forum.servoy.com/t/request-focus-help/1184/10 "2004-03-28T01:49:21Z")

</div>

not yet.. will be there very soon
