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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -