requestfocus generalised

Situation: field a,b,c

on datachange in field b I correct the value in field a. This happens when the user tabs out of the field. So he expects to have the cursor in field c.

However since I’m changing values in field a the cursor ends up in field a.

Now I know I can use elements.requestfocus.fieldC to correct this. However the problem is that I have to name those fields, which makes it , with my little knowledge of Servoy, impossible to promote the method to the global level.
What I am looking for I suppose is some kind of ordered( by tab order) Array form.fields in which I can retrieve the Index position of the field I’m tabbing out so I can retrieve the next field
So requestfocus could look like:
form.fields[currField+1].requestfocus()

Hope this makes sense and please advise

Since 1.2 rc5 it is possible to set the tabOrder for fields, this is what I think you are looking for.

only if I can ask through a method (GET) current tabIndex (that would be the tabIndex of field b. Then I need to GET the fieldname of current TabIndex +1 in such a way that I can in a method say elements.Fieldname(current TabIndex+1).requestFocus(). If this is possible I sure would like to see an example.

To be more clear: I don’t want to set the taborder. I want a generalised method that says : on datachange(in field b) change a value in another field(a),but position the cursor in field c where c= tabIndex field b +1.

I want a routine that can be invoked from anywhere (so on the global level) that changes the zipcode when the cityname is changed and the cursor has to end up in the next logical(after city) field. Since Zip and City are at least in 4 forms the field after city is not always the same so element.NAMEDFIELD.requestfocus is not good enough

TIA

What you want is not possible…
There are 3 options:
-disable the field you want to skip (so it is skipped during tab)
-name the field after postalcode field the same on all forms
-make the scripts form based instead of global.

Hmm, not yet ready to give up. Learning alot from these trials. I think I found a solution, but one element is still lacking

Is there a way of knowing what field triggered a method

field a : on datachange( DoAMethod())
field b: on datachange( DoAMethod())

How do I distinguish on what field the method was triggered,who called the method. Do we have something like the “this” function in javascript?

Odysseus:
Hmm, not yet ready to give up. Learning alot from these trials. I think I found a solution, but one element is still lacking

Is there a way of knowing what field triggered a method

field a : on datachange( DoAMethod())
field b: on datachange( DoAMethod())

How do I distinguish on what field the method was triggered,who called the method. Do we have something like the “this” function in javascript?

It is possible to do what you require.

Your method will need to know what the next logical field is according to each of the possible forms where this type of action may happen. You will need to use some type of test that tests for the current contoller form the user is currently on.

You would then need a method for each form targeting each target field with the requestFocus() function. You could then call that requestFocus method dependant upon the form that has control.

Hope this makes sense, but it is possible to do what you need.