I have the following javascript code:
function ClickButtons() {
document.getElementById('Button1').click();
document.getElementById('Button2').click();
}
only Button2 seems to be clicked. If I reverse the order of the statements then only Button1 (which would be called 2nd then) seems to work.
FYI (don't think this is impacting this issue, here for futher information): The button clicks are doing ajax/partial page updates (they call data services and populate data on the page)
EDIT: The solution setTimeout works, but puts an lower bound on performance. I've done a bit more looking and the two buttons are asp.net buttons and are inside update panels. If I click them sequentially they work fine, but if i click one and then quickly click a second one (before the first has completed) then the second one will work and the first will fail. This appears to be an issue with update panels and asp.net? Is there anything I can do on that front to enable the above javascript and avoid the setTimeout option?