2

I have a dropdownlist which is declared as follows:

<select onchange="reloadValues(this,event);">
... options here 
</select>   

When the user change the selection reloadValues is invoked and everything works perfectly. Now, I want to add the reloadValues when the user adds a new row which contains the dropdownlist so I did the following:

reloadValues(rowToBeAdded.find("select")[0]);

The reloadValues function is shown below:

 function reloadValues(obj, event) {
    {
            var ele = obj.parentElement.parentElement;
            var select2 = ele.cells[2].childNodes[1]; // ele.cells is empty when invoking // the reloadValues on demand through another method. 
    }

Any ideas!

obj.parentElement.parentElement is a TR element

1 Answer 1

1

I hit this problem once because I was accessing cells before the <tr> element was added to the document. At least Internet Explorer 8 returns an empty cell collection in this situation.

So, try appending rowToBeAdded to your table before calling reloadValues().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.