This is a migrated thread and some comments may be shown as answers.

[Solved] Client-side Focus

1 Answer 146 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeroen Eikmans
Top achievements
Rank 1
Jeroen Eikmans asked on 29 Oct 2009, 08:48 AM
Hi,

I have 2 comboboxes on a page. When the user changes the first combobox i would like to focus the second one.
I'm using the OnClientSelectedIndexChanged event of the first combobox to achieve this. On IndexChanged calls the following javascript method
function FirstComboBox_IndexChanged(sender, args) {  
    var comboBox = $find("secondRadComboBox"));  
    if (comboBox != null) {  
        var input = comboBox.get_inputDomElement();  
        window.setTimeout(function() { input.focus(); }, 0);  
    }   

At first i just called input.focus() but i found this post stating i should call window.setTimeout(function() { input.focus() }, 0)
I debugged the code and the focus method gets called but the second combobox doesn't get the focus.

Is this something i can't do in the OnClientSelectedIndexChanged or do i have to call the focus method using another way?
Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 29 Oct 2009, 12:15 PM
Sorry, i should have looked a bit better.
There was a bug in my code which caused the FirstComboBox_IndexChanged method not getting the second combobox but the first one....fixed that and everything works perfectly now!
Tags
ComboBox
Asked by
Jeroen Eikmans
Top achievements
Rank 1
Answers by
Jeroen Eikmans
Top achievements
Rank 1
Share this question
or