Generate Random Number Within Range
July 10, 2013 12:00 AM
I'm trying to use javascript to generate a random number within a specific range, and assigning that number to a variable in Lectora (in this case, v_num).
I'm using a Run Javascript action with the following script:
function generatenumber()
{
var x = Math.floor(Math.random() * (100 - 50 + 1)) + 50;
Varv_num.set(x);
}
generatenumber();
[/CODE]
But, I get nothing. I'm fairly new to javascript (most of my programming has been .NET or SQL), so perhaps my code is bad... but I've looking around the forums and searching online and haven't found anything else that works. Any help would be appreciated![CODE]
function generatenumber()
{
var x = Math.floor(Math.random() * (100 - 50 + 1)) + 50;
Varv_num.set(x);
}
generatenumber();
[/CODE]
But, I get nothing. I'm fairly new to javascript (most of my programming has been .NET or SQL), so perhaps my code is bad... but I've looking around the forums and searching online and haven't found anything else that works. Any help would be appreciated!
Discussion (2)
Didn't know that existed... thanks!
Also, I just found that the script works properly when previewed in a browser, but previewing in lectora (whether using run, preview, or debug) it does nothing. weird...
Discussions have been disabled for this post