I've been researching a problem with onclick triggers that are actually triggered during page/window load, but I haven't been able to find a solution yet.
What I need is the ID of the latest clicked button, so I tried this:
var lastButtonId = [];//to store the latest Id
// then set up the onclick statements:
document.getElementById('traffBut').onclick = sendButtonId('traffButton');
document.getElementById('convBut').onclick = sendButtonId('convBut');
document.getElementById('revBut').onclick = sendButtonId('revBut');
document.getElementById('tranBut').onclick = sendButtonId('tranBut');
//Then here's the function to retrieve the last clicked ID:
function sendButtonId (clickedButton)
{
lastButtonId.splice (0,1,clickedButton);
console.log(lastButtonId);
}
However, when the page loads, the console displays this message: Click here to see console logs
I've tried various approaches to solve this issue but have been struggling with it,
Any hints or guidance would be greatly appreciated :)
Thanks in advance, J.