Hello, scratchers. I'm learning HTML, and I need help. How do you create a random number with a text after it? i tried this:
<script type="text/javascript"> var x=Math.floor((math.random()*11011) & "People online") document.write(x)
I searched EVERYWHERE ON THE INTERNET! Please help me.
Offline
I'm not an expert on JS, so sorry if I'm wrong, but I think you are missing a ")." Also, maybe there's another way to do it, but I use a "+" instead of a "&" for concatenation. So...
<script type="text/javascript"> var x=Math.floor((math.random()*11011)) + "People online") document.write(x)
Last edited by scmb1 (2012-03-04 16:20:24)
Offline
scmb1 wrote:
I'm not an expert on JS, so sorry if I'm wrong, but I think you are missing a ")." Also, maybe there's another way to do it, but I use a "+" instead of a "&" for concatenation. So...
Code:
<script type="text/javascript"> var x=Math.floor((math.random()*11011)) + "People online") document.write(x)
Thanks. I'll try it
Offline
poemon1 wrote:
scmb1 wrote:
I'm not an expert on JS, so sorry if I'm wrong, but I think you are missing a ")." Also, maybe there's another way to do it, but I use a "+" instead of a "&" for concatenation. So...
Code:
<script type="text/javascript"> var x=Math.floor((math.random()*11011)) + "People online") document.write(x)Thanks. I'll try it
![]()
And you left off the semi-colons.
<script type="text/javascript"> var x=Math.floor(Math.random()*11011) + " People online"); document.write(x);
Offline
scmb1 wrote:
poemon1 wrote:
scmb1 wrote:
I'm not an expert on JS, so sorry if I'm wrong, but I think you are missing a ")." Also, maybe there's another way to do it, but I use a "+" instead of a "&" for concatenation. So...
Code:
<script type="text/javascript"> var x=Math.floor((math.random()*11011)) + "People online") document.write(x)Thanks. I'll try it
![]()
And you left off the semi-colons.
![]()
Code:
<script type="text/javascript"> var x=Math.floor(Math.random()*11011) + " People online"); document.write(x);
Oh yeah...
lol.
Offline
<script type="text/javascript"> var x= Math.floor(math.random()*11011) + " People online"; document.write(x); </script>
Offline
Oh yeah, Math.random has to be capitalized.
Offline