I'm not the world's foremost Javascript expert, but the following may help.
Assuming you have a button and a text field. Give the text field a meaningful name, in the example below, it's called "randomNumber".
On the Actions tab of the button, enter a mouse up action with the following code:
function randomIntFromInterval(min,max)
{
return Math.floor(Math.random()*(max-min+1)+min);
}
var rNum = this.getField("randomNumber");
rNum.value = randomIntFromInterval(1,10);
In this example "1" is the minimum, "10" is the maximum.