Solved JavaScript random number generator?

April 5, 2012 at 22:15:29
Specs: Windows 7
Ok. I've never been interested in learning JavaScript but I have a site and I want to make a simple html thing that generates a random number (1-6 max could change) then uses a simple if statement and a simple document.write to make varying text. I also want it to only generate the random number if the variable is undefined. Here's what I got so far:
<script type="text/javascript">
//Test if null
var number=//random number generating code

if (number == 1)
document.write("Some text");
} else if (number == 2)
document.write("Some other text");
} else if (number == 3)
document.write("Some more text");
} else if (number == 4)
document.write("Text, Text, Text...");
} //.......
I also want some of it to appear italicized and some normal.

See More: JavaScript random number generator?

Report •

Report •

April 5, 2012 at 22:25:58
@Razor2.3 Ok. But what about the test if null. I searched this one a bit and found nothing that works. And the italicized thing.
EDIT Forget the italicized thing. I just need to use the italicized tag and since the non-italicized doesn't change I don't need to incorporate it.
EDIT Actually I got everything working now. Thanks. Best answer.

Report •
Related Solutions

Ask Question