Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Todd Kempf on Apr 06, 2009 08:50
open dhtmlx forum
Default Values in form

I am using the 100000 combo box example for populating zip codes in a form. The submit form works well, values are recorded to my database correctly. However, I have an edit form where I pull the values previously recorded out of the database. I then set up and edit form with those values using the combo box, here is what that looks like in my code, $value is the previously recorded value from the database:

<script>
function doOnLoad() {
var z=new dhtmlXCombo("combo_zone","Zip",200);
z.enableFilteringMode(true,"../dhtmlxCombo/samples/filtering/100000/loadCombo.php",true,true);
z.setComboValue("$value");
}
</script>

<div id="combo_zone" style="width:200px; height:30px;"></div>

I am using the value of ZIP_new_value to check whether the value is in the predefined list or not, if the value is false then I allow the edit to go through, if the value of ZIP_new_value is true, then I throw and error stating the zip code is invalid. My problem is upon the code above being executed the form looks correct, the value from the database is selected in the drop down correctly, but upon submitting the edit form the ZIP_new_value is true even though the zip is in the predefined list. How can I have the Zip checked while the list is populated so the variable id ZIP_new_value set correctly to false?

Wasn't sure how to handle this. Thanks for any suggestions.

Answer posted by Alex (support) on Apr 06, 2009 10:08

You can try to use the following approach:

combo.addOption($value,$value)
z.setComboValue("$value"); 


In this case $value will be marked as existent in combo.