Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Uthay on May 15, 2009 02:21
open dhtmlx forum
Combo box looses value when i press the tab button on my keyboard

I have got a combo Box which has the lists of 'status' and when i select a option and save it, it works perfectly as it keeps the value. But when i go back to the form again and tab out that field as i do not have to change the value and move to next textfield and save it and go back to the form it looses the value.

Can anyone tell me how i could solve this problem

this is my cose
[code]
zStatus =new dhtmlXCombo(getElementByIdCompatible(sLocation+"drpSTATUS_list"),sLocation+"drpSTATUS_list",500);
zStatus.setOptionWidth(500);
zStatus.enableFilteringMode(true);
zStatus.loadXML("combodriver.jsp?table=tblstatus&val=status");
zStatus.attachEvent("onBlur", updateStatus);
zStatus.setComboValue(getElementByIdCompatible("form1:txtSTATUS").value);

[/code]


[code]

function updateStatus() {
getElementByIdCompatible("form1:txtSTATUS").value=zStatus.getSelectedValue();

};

[/code]



Thanks

Uthay
Answer posted by Alex (support) on May 15, 2009 03:42

The value disappears after page reloading.... Am I right?

In this case you can try to save selected value in a cookie and then restore it after the page is reloaded. 

Answer posted by Uthay on May 15, 2009 03:53
Thanks Alex for your answer, but it is not loosing the value when i reload again. it is keeping the value but after the reload when i decided to change a value on different textfield i  TAB pass the combo box, at this moment it highlight the existing value and all look good now if i save and reload; it looses the value.



Answer posted by Alex (support) on May 15, 2009 04:15

The text can be shown afler reloading, but combo doesn't set internal properties in this case (as value isn't really set).

You can try to use the following approach after combo initialization:

...

zStatus.loadXML("combodriver.jsp?table=tblstatus&val=status",doAfterInit);

function doAfterInit(){

var text = zStatus.getComboText();

zStatus.setComboValue(text); /*the value is set*/

}

Answer posted by Uthay on May 15, 2009 06:22
A huge thanks to you Alex, That was a perfect Solutions

Thanks Mate