Form Post Back - Default Combo back to value user picked - U

Hi guys,



I am trying to use the combo box in the following situtation:



1. User selects option from combo box (combo box is population by dynamic page using filtering mode)

2. When user submits form, it comes back to the same page and shows the form again and the results found.

3. I would like the form to default to the choice that the user chose from the beginning.



Is this possible to do with using the dynamic filtering mode?



My code is as follows:



var z=new dhtmlXCombo(“GroupIDBox”,‘EmployerIDNumber’,250);

z.enableFilteringMode(true,"…/include/xml-list-of-groups.asp?Selected=<%= strEmployerIDNUmber %>",false,false);



How can I make the default go to the value they picked (which is strEmployerIDNumber)? I have a lot of values so I cannot use a straight xml load.



Please let me know if you can think of anything. Thanks and have a great day.



Best,

Lou

You must know both id and label of selected option to restore it after reload ( actually it possible to restore necessary view by id only, but it will require a complex code in case of dynamic filtering )

var z=new dhtmlXCombo(“GroupIDBox”,‘EmployerIDNumber’,250);

z.enableFilteringMode(true,"…/include/xml-list-of-groups.asp?Selected=<%= strEmployerIDNUmber %>",false,false);

z.setComboValue(value_part);
z.setComboText(text_part);

where text_part - option text
           value_part - database ID

Works perfectly, you guys are great.


 



Then I need this complex code…



 


To be precise, here is what we need to do:



In case of small combobox (1-100 values):
1. User selects option from combo box (generated using dhtmlXComboFromSelect)
2. When user submits form, it comes back to the same page
3. The option previously selected by the user is shown
=> This works OK



In case of large combobox (>100 values, we want dynamic filtering):
1. User selects option from combo box (using enableFilteringMode)
2. When user submits form, it comes back to the same page
3. The option previously selected by the user is NOT shown
=> How can we do this ? (The code showing the page does not know anything about the selected option text… but just the ID)



Regards,
Jean.

Instead of
z.setComboValue(value_part);
z.setComboText(text_part);

you need to use

z.setComboText(text_part);
z._load=“complete.php?mask=”+text_part;
z.loadXML(z._load,function(){ //mimic dyn. load data request
z.setComboValue(value_part); //set value after related part of data loaded
});






 



?
Sorry, I don’t get it.
I mean I actually don’t have the text_part.
I just have the value_part (once the user has selected an option, only the value_part is submitted to the server).
So I can’t use the “z.setComboText(text_part);”



Regards,
Jean.

In such case the only way is adding additional server side logic.

z._load=“complete.php?mask_value=”+value_part;
z.loadXML(z._load,function(){ //mimic dyn. load data request
z.setComboValue(value_part); //set value after related part of data loaded
});

The complete.php, must check if $_GET[“mask_value”] exists, and in such case it need to select text of related option, and continue processing for it

if (isset($_GET[“mask_value”])){
$_GET[“mask”] = some_method_to_get_text_by_value($_GET[“mask_value”]);
}
… common autocomplete code …


Ok, clear answer.



Thanks!