Copy link to clipboard
Copied
I am completely new at javascript and I don't know all the terminology so it might take some dumbing down in response. I am attempting to generate a random number between 0 and 1 so I would like it to look like .1234 or .9999. It has to be four digits and I don't necessarily need it to lock once entered. I would only need to print that page and hit my radio button and generate a new list of numbers. I currently have this as my script.
this.getField("Text1").value =
Math.floor(Math.random()/Math.pow(10000,4));
The "Text1" is the current name for the box on my test page and I am using a radio button to generate the number. I will also have multiple boxes that I want random numbers generated in and I would like to use one radio button to complete the task of generating all the random numbers that I would need. How would I also add, say "text2, text3, text4", boxes to this so that all of them would have a separate random number or do I have to enter a script to each "text" box to do this.
Thanks
JavaScript Random numbers are already between 0 and 1, so all you need is some formatting.
this.getField("Text1").value = Math.random().toString().substr(0,6);
Copy link to clipboard
Copied
JavaScript Random numbers are already between 0 and 1, so all you need is some formatting.
this.getField("Text1").value = Math.random().toString().substr(0,6);