By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

setting focus to a tabe cell.

P: n/a
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..

Sep 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Pr**************@gmail.com wrote:
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..
Sep 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.