471,601 Members | 1,203 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,601 software developers and data experts.

setting focus to a tabe cell.

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
1 2387
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.

Similar topics

6 posts views Thread by joe | last post: by
3 posts views Thread by Darrell Wesley | last post: by
8 posts views Thread by jonny_morrisuk | last post: by
2 posts views Thread by lasher168 | last post: by
1 post views Thread by Lcoggshall | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.