Set Focus

  
Hi...
I've looked around to see if I can find a way o insert some data on my third input box, click on enter , and when the page refresh , the focus is set to 3rd inputbox again...

This alow me to use a barcode reader to register some barcode info...

I've tryed some javascript on onload event but something wasn´t right...

it didn't work...
could you point me to an exemple!??!
tanks,

Miguel
Greetings!

To set the focus on an input box you may add the following function to your eSpace/WebScreen javascript.

function setFocus (id) {
var textBox = document.getElementById (id);
if (textBox != null) {
textBox.focus();
}
}

Now, assuming the name of the input box is InputMyInput, call the function from the onload event handler using "setFocus('wtInputMyInput');".

Besides setting the focus, you may also need to highlight the text in the input box. For that you may replace the previous function with this one:

function highlightText (id) {
var textBox = document.getElementById (id);
if (textBox != null) {
textBox.select();
}
}

I have attached a sample eSpace for this last one.

Hope this helps,

Paulo
Hi,

For Focus on the right place use this function at onload event!
Automatically search for the next empty input and Set Focus!


function SetOSAutoFocus() {
var texts=document.getElementsByTagName('input');
for (var i_tem = 0; i_tem < texts.length; i_tem++)
{
if (texts[i_tem].type=='text')
{
if (texts[i_tem].disabled==false && texts[i_tem].readOnly==false && (texts[i_tem].value=='' || texts[i_tem].value=='0'))
{
texts[i_tem].focus();
break;
}
}
}
}
Hi,

Just to let you know that this functionality is now provided by the SetDefaultInput web block of the WidgetLibrary, so you don't have to do it manually with JavaScript. This web block is also used in the StyleGuide in the login page, so you can check there as an example usage.

Best Regards,
Gustavo Guerra