Try this demo.
HTML
<input type="button" id="start" value="Generer" onclick="startInterval();" />
<input type="button" id="stopp" value="Stopp" onclick="stoppInterval();" />
<p id="boks"></p>
JS
var timer,
counter = 0;
function makeNew() {
document.body.appendChild( document.createElement('div') );
counter++;
document.getElementById('boks').innerHTML += 'box('+counter+'),';
}
function startInterval() {
timer = setInterval(makeNew, 50);
}
function stoppInterval() {
clearInterval(timer);
}
Update: Looking at your question may be you are trying to get this http://jsfiddle.net/aamir/84HgL/2/