Copy link to clipboard
Copied
Guys, how to make the callback of each button?
How to call a function for each button
Thanks
var dialog = new Window("dialog"); dialog.text = "Dialog";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
array=["B1","B2","B3","B4",]
for (i = 0; i < array.length; i++) {
array[i];
bt = dialog.add("button"); bt.text =array[i];
}
dialog.show();
var dialog = new Window("dialog"); dialog.text = "Dialog";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
array=["B1","B2","B3","B4",]
array2=[f1,f2,f3,f4]
for (i = 0; i < array.length; i++) {
array[i];
bt = dialog.add("button"); bt.text =array[i]; bt.onClick = array2[i];
}
dialog.show();
function f1() { alert(1); }
function f2() { alert(2); }
function f3() { alert(3); }
function f4() { alert(4); }
Copy link to clipboard
Copied
var dialog = new Window("dialog"); dialog.text = "Dialog";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
array=["B1","B2","B3","B4",]
array2=[f1,f2,f3,f4]
for (i = 0; i < array.length; i++) {
array[i];
bt = dialog.add("button"); bt.text =array[i]; bt.onClick = array2[i];
}
dialog.show();
function f1() { alert(1); }
function f2() { alert(2); }
function f3() { alert(3); }
function f4() { alert(4); }
Copy link to clipboard
Copied
Perfect @r-bin! Thank you so much for sharing your knowledge