Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1

    Question HTML: On button click, show number from list.?

    Hello
    This is what I'd like to do:

    Click on a button, then a 4 digit number appears.
    This 4 digit number will be one of a five hundred, say, that have already been generated.

    So basically, when you click the button, it picks a random number from the number list.
    Is there a HTML code for this (or a code that will work in iWeb)

    If that makes sense, just say if i haven't explained properly.

    Thankyou!

  2. #2

    Default

    no it seems what you looking for is a random number script you would have to use javascript or another scripting language

  3. #3

    Default

    could I use PHP?

    How would I do it with code (php or javascript)?

  4. #4

    Default

    ill post it for javascript below:

    <html>
    <head></head>
    <body>
    <h2>The random number produced was
    <script type="text/javascript">
    document.write(
    Math.floor(Math.random()* 11)
    );
    </script>
    </body>

    the 11 means the random number will be between 0 and 11

  5. #5

    Default

    Okay thankyou, but could I have a 4 digit number that's selected from a predefined list (that i've made), instead of just a random number between x and y?

  6. #6

    Default

    hmm give me an example and ill tweek it for ya

  7. #7

    Default

    So, I have five 4-digit numbers, this is my pre defined list.
    1982
    5982
    7391
    9263
    3681

    I want a 4 digit number that's selected from my predefined list.
    So, the script randomly picks one of the above numbers (in the list), but not any old 4 digit number.
    E.g. It could pick 1982 (because it's in the list) but not 1234 (because it's not in the list)

    That any help?

  8. #8

    Default

    ok give me like 15 mins to create it for ya

  9. #9

    Default

    cheers buddy!

  10. #10

    Cool Here

    here it is:

    <html>
    <head></head>
    <body>
    <h2>The random number produced was
    <script type="text/javascript">

    var random = Math.floor(Math.random()* 4)

    switch(random)
    {
    case 0:
    alert("1982");
    break;
    case 1:
    alert("5982")
    break;
    case 2:
    alert("7391");
    break;
    case 3:
    alert("9263")
    break;
    case 4:
    alert("3681")
    break;
    </script>
    </body>

    This will set an alert once a page is loaded, the alert will have the 4 digit code in it:dance:

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •