Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by water on Jan 15, 2008 19:29
open dhtmlx forum
Set focus

Hi,

Can I set focus for the combobox by javascript/script such as setTimeout(.....?

How can I get back the header textbox by
document.getElementsByName("....") / document.getElementByID("....") to set .focus()??

Thanks.
Answer posted by Support on Jan 16, 2008 07:25
If you have combobox object
    var c = new   dhtmlXCombo( ....

You can focus cell by

    c.DOMelem_input.focus();


Or if you have specific form name
    var c = new   dhtmlXCombo("my_div","input_name");
you can focus by such name as
    document.getElementsByName("input_name")[0].previousSibling.focus();
Answer posted by water on Jan 16, 2008 20:29

Hi,

Thanks for ypur answer but it seems that is does not work for   

var c =dhtmlXComboFromSelect ("c","c_text");

The combobox will disappear. (I think it should be error.)

 

However, I view the codes and find the line 1080 can set the id for the simulate combobox. Thanks a lot.

Answer posted by Daniel on Mar 30, 2008 20:24

I am also facing the same problem, but looking the suggested solution as being:

document.getElementsByName("input_name")[0].previousSibling.focus();

 

is way too complicated to do or put in our code. We aim at making our code simple and readable without the need to do deep div in DOM programing.

Since this has a common usage I think it should be an API call to XCombo.

 

Daniel

 

Answer posted by Daniel on Mar 30, 2008 20:29

By the way, what is this:

var c = new   dhtmlXCombo("my_div","input_name");

I can't see this type of object intitialization in the documentation. Instead what we have is  something like this:

var c = new   dhtmlXCombo("my_div","alpha2", 200);

 which I don't know what alpha2~4 is all about?

Daniel

Answer posted by Support on Mar 31, 2008 04:10
>> but it seems that is does not work for  

Actually, in case of using document.getElementsByName("input_name")[0].previousSibling.focus(); approach there can be an issue in IE (in FF all works correctly) - IE cann't find an element which was created dynamically.

So, please, try to use the following approach:

    c.DOMelem_input.focus();

If problem persists, please, provide sample directly to  support@dhtmlx.com.