I don't know that I would have figured that one out Paul, thanks.
The clue to the onClick problem was the distance between the client buttons. It pointed to the button_top/bottom values being changed in the onProjectChange function. Then I used some alerts to confirm it. i.ealert("Loop " + j + " Button Top = " + button_top);
alert("Why am I in the onProjectChange function?");
It seems to be updating on the click now. I have a new problem that's stumping me.
I had noticed that you aren't storing the buttons:
rbutton = addProjectButton(dlg.ClientPnl,[button_left,button_top,button_right,button_bottom],sClient);
It appears "rbutton" will just get replaced on each iteration of the loop.
Maybe if you had a couple of arrays to store the client/project buttons, you could just reuse them by renaming/turning invisible when you want them to change.
It'd be useful if you could put more comments in the script. I've been having some trouble following exactly what's going on (i.e what some of the variables are used for, how the client/project data is stored, what the getProjectList function is doing)