1. the onChange event on my combos doesn’t seem to trigger until I click on another element, is there some way I can make it trigger as soon as I move the mouse out of the combo input area similar to the OnBlur event?
2. I have multiple combos on a page which have the same option list.
I have successfully used dhtmlAjax to add any new options entered to my db.
Now I am trying to add the new option to the combo updated and the other duplicate combos.
I am building the array to rebuild the options in the php page I use to update the db, and have checked that loader.xmlDoc.responseText returns the following:
[[1,‘Baking’],[2,‘Beverage’],[3,‘Breakfast’],[4,‘Christmas’],[5,‘Cleaning Product’],[6,‘Confectionery’],[7,‘Dessert’],[8,‘Entree’],[9,‘Main Meal’],[10,‘Marinade’],[11,‘Microwave’],[12,‘Side Dish’],[13,‘Snack’],[14,‘Test’],[15,‘Test1’],[16,‘Test2’],[17,‘Uncategorised’]]
I thought I could plug this into addOption and rebuild the option list as in the code below, but it doesn’t work. THe option list gets cleared, but the new options don’t appear. Am I on the wrong track?
3. Can I omit the value field when using addOption, as I don’t need it?
>> the onChange event on my combos doesn’t seem to trigger until I click on another element, is there some way I can make it trigger as soon as I move the mouse out of the combo input area similar to the OnBlur event?
onChange occurs when enter key is pressed or you press somewhere and combo loses focus.
There is onBlur event too.
>> THe option list gets cleared, but the new options don’t appear
addOption method requires array, not string. Combo can be also loaded from xml file or string: loadXML(url), loadXMLString(string)
>> Can I omit the value field when using addOption, as I don’t need it?
No, you shouldn’t do that
If I want to use loadXMLString, what do I have to return from the php script and what JS code do I need to use to load the options?
loadXMLString requires xml string. For example:
This is all working perfectly now -thanks!!
However, just to let you know - using the xml string format you provided I ended up with both the value and the text being added to my option list. To correct this I omitted the value parameters like this
value attribute is obligatory. So, you should add it to use combo API.
That being the case, how can I stop the value being added to my option list as stated above?
>> how can I stop the value being added to my option list as stated above?
the value attribute is obligatory. It must be used. There is no possibility to change this behaviour.