Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: I have a Question( Try to make 1 HTML)

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I have a Question( Try to make 1 HTML)

    I want to make some this like this.

    Write a JavaScript program that will pick randomly ONE museum from a list of 10 museums in Kuala Lumpur to visit. The choices are listed below:



    a) Bank Negara Money Museum (Muzium Matawang Bank Negara)

    b) Biomedical Museum

    c) Islamic Arts Museum Malaysia (Muzium Kesenian Islam Malaysia)

    d) Maybank Numismatic Museum

    e) Malaysia Telecommunications Museum (Muzium Telekomunikasi Negara)

    f) National Museum (Muzium Negara)

    g) National Textile Museum Kuala Lumpur (Muzium Tekstil Kuala Lumpur)

    h) National Museum of History (Muzium Sejarah Nasional)

    i) Royal Malaysian Air Force Museum

    j) Royal Malaysian Police Museum (Muzium Polis Diraja Malaysia)

    i want to use the selection statement for the choice of museum.

    i want to use the Math.floor and Math.random methods to get the random number (I dont Understand).

    i want my page have an html form with a simple one-line text box that should display the name of the museum.

    i want have a button that when pushed will invoke a JavaScript function that randomly chooses and displays the museum name into the text box.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: I have a Question( Try to make 1 HTML)

    Try a javascript forum. This one is for java.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: I have a Question( Try to make 1 HTML)

    Even though, what you've tried?
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

  4. #4
    Junior Member
    Join Date
    May 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: I have a Question( Try to make 1 HTML)

    I dont really know this Java but maybe its something like this

    __________________________________________________ __________
    <html>
    <body>

    <p id="demo">Click the button to display a random number.</p>

    <button onclick="myFunction()">Try it</button>

    <script type="text/javascript">
    function myFunction()
    {
    document.getElementById("demo").innerHTML=Math.ran dom();
    }
    </script>

    </body>
    </html>

    __________________________________________________ _____________________

    but when i click the button i would like to make a museum will randomly choose from list,
    My Coding above just random number, i dont know how to make it.
    Can someone help me please...

  5. #5
    Member
    Join Date
    Apr 2012
    Location
    Superior, CO, USA
    Posts
    80
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default Re: I have a Question( Try to make 1 HTML)

    In JavaScript (which is what your requirement is, not Java) to generate a number between 0 and 9 you'd do something like:

    var index = Math.floor(Math.random() * 10);

    An array of strings would look something like:

    var museums=['number1', 'number2', 'number3'];

    Does this give you any ideas?
    Last edited by stdunbar; May 17th, 2012 at 10:03 PM.
    Need Java help? Check out the HotJoe Java Help forums!

Similar Threads

  1. Replies: 4
    Last Post: October 24th, 2011, 08:09 AM
  2. [SOLVED] Make JTextArea Support HTML
    By bgroenks96 in forum AWT / Java Swing
    Replies: 12
    Last Post: August 28th, 2011, 01:01 PM
  3. Beginner Question Here (Trying to make things easier)
    By beer-in-box in forum AWT / Java Swing
    Replies: 2
    Last Post: June 1st, 2011, 10:48 AM
  4. Question About servlet and HTML
    By kurt-hardy in forum Java Theory & Questions
    Replies: 5
    Last Post: January 14th, 2011, 09:25 PM
  5. please solve this question on html:multibox?
    By tejz in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: February 13th, 2010, 03:18 AM