var m = 3; var n = parseInt(Math.random() * m + 1, 10); switch(n){ case 1: break; case 2: document.write('; break; case 3: document.write('; break; }