setting focus to a tabe cell.

P

Praveena.Alapati

Hi,

There is a tab control on a page with multiple tabs and handful of
controls in each tab. The way it's rendered in html (like grid etc..)
is in table format in tablerows and cells.

On clientside, on form validation in javascript, I would like to set
focus on to one of the tabs
and set the focus to the control on that tab.

I find this (tab) control by looking through all 'td' s and by it's id.
Now that I have "td" control, I would like to set the focus on to this.


Here is what I do. (FindHtmlControlByID method returns the control
based on type and id)

firstTab = FindHtmlControlByID('TD','UltraWebTab1td0');
secondTab = FindHtmlControlByID('TD','UltraWebTab1td1');

secondTab.style.visibility = 'visible';
secondTab.focus();

textBox = FindHtmlControlByID('INPUT','uiTextBox1');
textBox.style.visibility = 'visible';
textBox.focus();

textBox.focus() fails with the message it's either not visible or not
enabled or it is a type of control that cannot be focused. If the tab
already had focus, then this works ok.

If anybody have an answer, please respond.

Thanks for your time in advance..
 
Y

Yanick

Why don't you use CSS to show that a tab is active, or inactive ?

You already have both tabs ; I presume that "firstTab" is your tab to
lose focus, and "secondTab" is your tab to get focus, then :

firstTab.className = 'tabNoFocus';
secondTab.className = 'tabFocus';

instead of calling the focus(); method to the table cell elements. Try
to see that method (fucus) as a "give me focus to that element so I can
edit it" method, rather than "select this element". If you can't edit
an element, you shouldn't try to get focus on it.

Using CSS, as described above, will give the apearance to the user that
the tab has been selected, while the other one lost it's selection.

I hope this helps.

-Yanick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top