Filtering and Editing records...

I have created a php front end to a database which allows you to browse edit and add records to a contacts database. I’m using dhtmlxCombo for the ZIP code field in filtering mode. I used the sample code in the file: dhtmlXCombo/samples/filtering/100000/loadCombo.php as a template.

Everything works great if entering new data into the database, my problems exist when editing. My editing call for the zip code field looks like:

        elseif (preg_match('/Zip/',$field)) {
           $ZipCODE=GetZip($value); // Gets ZipCODE from ZipID
           RelateZip($ZipCODE,$color);  //Obtains State and City info from the zip code
           print"<tr class=$color><td class=borderleftright><FONT class=mainfont><b>".preg_replace("/_/"," ",$field).":
<div id=“combo_zone” style=“width:200px; height:30px;”></F
ONT>\n";
        }

If you do not re-select the zip code drop down each time you edit, the database is populated with blank data, which wipes out the persons zip code. If you re-select the zip code from the drop down each time things work fine.

Any ideas how to work around this? Really just want to edit the appropriate fields and be done and not have to worry about touching the zip code each time to ensure the data is correctly inserted.

Thanks for anything that come to mind.
Todd

You may call filterSelf() method to filter combo with the text:

z.setComboText($value);
z.filterSelf();

This doesn’t seem to be working, I have tried setting z.filterSelf($ZipCODE); and still upon saving my edited record I get a blank for the zip code. Only works if I “click” on the zip code each time from the drop down. This call made the zip code drop down select the proper zip, but I still have to click on it to select it. If I don’t click on it the zip code is wiped out.

Code is now as follows:
print"

".preg_replace("/_/","",$field).": <div id=“combo_zone” style=“width:200px; height:30px;”> \n";

I would really like to be able to edit a record without having to select the zip code each time. Most of the time I am not editing the zip code but other data. If I forget to touch the zip code field it is still wiped out.

Thanks for your further help.

I’m having the same issue. My form is bound to my grid and when I select a row from the grid my combo boxes fill correctly (at least the text part of it) but when trying to save or getSelectedValue() I only get null unless I manually go re-select the value.

In my case it was an issue of binding a combo box to a simple text field in my grid - which the combo box expects to receive the value from the grid, NOT the label.

So to get around that I added additional “hidden” columns to my grid that housed the ID’s (or “value”) and named them the same as the combo boxes in the form.

I don’t know if you’re in a similar situation but in the off-chance you are, that’s my advice.

Try to add “onXLE” event handler that will set combo value after the xml is loaded:

[code]var h = combo.attachEvent(“onXLE”,function(){
this.detachEvent(h);
this.setComboValue(value);
});

combo.setComboText(text);
combo.filterSelf();
combo.closeAll();[/code]

blankensa thanks for the idea, I made similar changes to my code and now its working fine. Used a hidden field and logic in my database update php file which determines if the Zip code was edited or not. If not it saves the OLDZip hidden value to the database.