I am working on a code to generate multiple buttons depending on user input
for(var loop = 0; loop < up.length ; loop++){
document.write('<button style="background-color:'+ up[loop] +';width:100;height:100" </button>');
}
however I want to have same onclick function for every button,but if I use like the one below, the function doesn't gets executed . What's the problem and where am I going wrong? Please help.
document.write('<button style="background-color:'+ up[loop] +';width:100;height:100" onclick= "myfn()" </button>');