Hi,
Please note SHOUTING does not help.
Using the code above you could easily modify that to generate a number on a button click but removing the if from the code and placing this on a button click and assigning it to a field;
var d = new Date();
fieldName.rawValue = Math.floor (d/1000);
however as John stated this does not actually give you a random number as it relies on a date and could in theory result in the same number at some point so I would use
fieldName.rawValue = Math.floor(Math.random()*11); // this would give a random number between 0 and 10, if you want it in a different limit change 11 to something else.
Hope this helps
Malcolm