How to add attach event for multiple calender dynamically

Hi,
I am creating the combo box in each of the table cell dynamically using javascript.
and not able to create the attach event for each of the dhtmlx combo.
Here is the code sample.
Kindly help in the issue.

function CreateComb()
{
var DhtmlxComb = new Array();
for(i=0; i<5; i++)
{
var cell = document.createElement(“td”);
var row = document.createElement(“tr”);
var comb = document.createElement(“select”);
var option = document.createElement(“option”);

        comb.id="combid"+i;
        option.text = "One";
        option.value = "1";
        comb.appendChild(option);
        option.text = "Two";
        option.value = "2";
        comb.appendChild(option);
        
        cell.appendChild(comb);
        row.appendChild(cell);
        document.getElementById("some_table").appendChild(row);
        
        DhtmlxComb[i] = dhtmlXComboFromSelect("combid"+i);
        DhtmlxComb[i].attachEvent("onChange", function()  {alert(DhtmlxComb[i].getSelectedValue());}); 
    }
}

Re: How to add attach event for multiple “COMBO” dynamically

Hi,

Try to use:
DhtmlxComb[i].attachEvent(“onChange”, function() {alert(this.getSelectedValue());});

instead of
DhtmlxComb[i].attachEvent(“onChange”, function() {alert(DhtmlxComb[i].getSelectedValue());});

this inside an event handler points to a combo object where the event has occured.