cannot pass argument to a simple javascript function -
the code below _______________ works is. creates table. append button @ end of each row (see .insertadjacenthtml below) calls restart() function.
however, if following: onclick="restart('restarted')" , add parameter function restart, directly below, not work.
all of happening in 1 .js file.
function restart(msg) { alert(msg); } //____________________________________________________ function restart() { alert('restarted'); } //add data rows. (var = 1; < uuts.length; i++) { row = table.insertrow(-1); (var j = 0; j < uutcount; j++) { var cell = row.insertcell(-1); cell.innerhtml = uuts[i][j]; } cell.insertadjacenthtml('beforebegin','<button \ onclick="restart()">restart</button>');
you need escape quotes:
.insertadjacenthtml('<button onclick="restart(\'restarted\')">restart</button>');
Comments
Post a Comment