I add some buttons dynamically with javascript depending on the value of a select box. This is the code for the button:
var cancel = document.createElement("button");
cancel.innerHTML = "Cancel";
cancel.type = "button";
cancel.onclick = location.reload();
container.appendChild(cancel);
This button is added to a modal dialog and should reload the page when it is clicked. If the function with which the button is added to the modal dialog is executed, the onclick event is also executed although the button was not clicked. Can anybody help me please? Thanks