Auto tab to next form field

I suspect I need to put some keyup action JS code in each element that I want to auto-tab
No, the code should already do that - it wll add the behaviour to any dom node that matches:

Code:
document.getElements('input.fabrikinput[type=text]');


If number entered into a field = 1 then maxlenth = 2 else maxlength = 1
Not sure what you mean here.

The code as it is uses the HTML field's maxlength property (which you can set in the elements admin options), when that is reached the next field is selected
 
Hi Rob

Thanks for the response. When you say "it wll add the behaviour to any dom node that matches:" is that effectively the same as "this in a X.js file in components/com_fabrik/js where X is your form id"? Sorry but I am a beginner using these methods so the language is difficult to understand.

I can see that I need to set maxlength in the element so will give that a try.

What I mean by "If number entered into a field = 1 then maxlenth = 2 else maxlength = 1" is that I wanted code that would use something like php's if...then..else so that if a user entered the number one in the form field the code would set the max length to 2 and move to the next field only if 2 digits were entered (10, 11, 12 etc), whereas if the user entered any other number (other than one) in the form field the code would set the max length to 1 and move to the next field after the one digit (0, 2, 3, 4 etc) was entered. However, I can think of situations where this if..then..else rule might not apply to every field so was thinking the code needs to be able to take parameters from something entered into the javascript section of each element rather than globally applying the rule to all fields on a given form.

Any further thoughts would be much appreciated

Regards
--Joe
 
is that effectively the same as "this in a X.js file in components/com_fabrik/js where X is your form id"?
You would need to put the code I posted in a X.js file. I presumed you had got that as that is what Hugh was implying from his first reply.

What I mean by "If number entered into a field = 1 then maxlenth = 2 else maxlength = 1" is that I wanted code that would use something like php's if...then..else so that if a user entered the number one in the form field the code would set the max length to 2 and move to the next field only if 2 digits were entered (10, 11, 12 etc), whereas if the user entered any other number (other than one) in the form field the code would set the max length to 1 and move to the next field after the one digit (0, 2, 3, 4 etc) was entered. However, I can think of situations where this if..then..else rule might not apply to every field so was thinking the code needs to be able to take parameters from something entered into the javascript section of each element rather than globally applying the rule to all fields on a given form.
Well that complicates things considerably, and I'm not sure it would be user friendly? What if they wanted to enter '1' but it didn't auto tab to the next field, where as other fields did auto-tab. It would then appear to the user that perhaps a '1' was not an appropriate value? I think you can over complicate these things to a point where they become a hindrance to the user rather than a help.
 
Hi Rob

Thanks - when I get home I will try your suggestion. In the meantime though is it possible to do what I requested albeit more complicated. I take on board your usability comment but still wish to pursue the if...then...else approach

---Joe
 
Hi Joe

Anything is possible, but if your JS chops are not there then its going to be hard.

I don't mind giving a starter as to how to do things but doing it all for you is no longer support and more in line with custom development which I'd have to charge you for.
 
Hi Rob

Thanks - just a starter will do - I want to learn and have time - I see www schools has some tutorials so some pointers would be much appreciated and I will do some trial and error plus reading

---Joe
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top