Javascript Help
- Started
- Last post
- 2 Responses
- ILuvSushi
Hi im trying to create a Form Field where a user can generate random numbers. E.G. I input 5 and hit Showme, an alert box pops up with 5 randomly generated nunbers generateNumbers()
when the user would click ok on the alert it would erase the form field where they inputted 5
Does anyone know of a script for this or possibly have a tutorial. thank you.
- o0o0
well... I don't know of a tutorial.. but lets see if this will help....
when you get the value out of the text field it will be a string, so you can use
intval = parseInt(txtvalue)
to make sure it's an integer...
then you can use that value in a for loop like this:sAlert = "";
for (i=0;i<intval;i++){
sAlert += Math.random() + ", ";
}
alert(sAlert);Math.random() give you a number between 0 and 1, so if you want something else (say between 1 and 5) then multiply (*5)...
that javascript might get cut out.. I'll mail it to you if it did...
- o0o0
whoa, yeah, that got messed up, I'll mail you that loop...