views:

36

answers:

2

function showSchedule() {
    if (request.readyState == 4) {
        if (request.status == 200) {
            document.getElementById("content").innerHTML = request.responseText;

            /* put alert to enroll submit button */
            document.getElementById("enroll").onclick = doIt;
        }
    }
}

function doIt() {
    alert("tu$a bastIn");
}

enroll is a button in coming with in request.responseText. I debug and see document.getElementById("enroll") is there (not null) but i can not assign doIt function. Any suggestions ?

A: 

I check wheather document.getElementById("enroll") is null or not and now it works. Thanks.

Altug
+1  A: 

when document.getElementById("enroll") is not null, then you have several elements with this id (may also be detached).

you overwrite some content where this id is present or have used this somewhere else.

Lauri