Two almost identical bits of javascript on one page, only one works
<p>long time reader, first time poster, always found the Stack Overflow community really helpful though, so thought it was time I got involved.</p>

<p>I have to generate two random numbers on my page. I'm using this javascript:</p>

<pre><code>&lt;script&gt;
 window.onload = generateRandomNumber1;
 function generateRandomNumber1(){
     var n = 30;
     var number = Math.floor(Math.random()*n)+1;
     document.getElementById("random1").innerHTML = number;
    }

 window.onload = generateRandomNumber2;
 function generateRandomNumber2(){
     var n = 30;
     var number = Math.floor(Math.random()*n)+1;
     document.getElementById("random2").innerHTML = number;
    }
&lt;/script&gt;
</code></pre>

<p>Only the second chunk of code, generateRandomNumber2, works. Both work individually, but only one works when they are together.</p>

<p>I'm sure there is probably some really basic solution, but I'm a real novice on javascript.</p>

<p>Thanks</p>
