Need help with some basic programming in Javascript

Discussion in 'Computer Programming, Emulation, and Game Modding' started by DarkSpace, Jan 6, 2009.

  1. DarkSpace
    OP

    Member DarkSpace Custom member title

    Joined:
    Aug 23, 2007
    Messages:
    551
    Country:
    United States
    Basically I'm learning how to program in Javascript.
    I don't get the java file that I have to make. It's to create a moon program that asks the user for their weight on earth and convert it to what they would weigh on the moon. Apparently it's a joption swing program. I have to add music to Html source and an image in the html. It's supposed to have dialogue boxes, which i understand. I just don't know how to get the number that people enter and use it in an equation. If anyone could help that would be amazing. Please don't flame me, I just started.
     
  2. chuckstudios

    Member chuckstudios Putting the pro in procrastination

    Joined:
    Jul 19, 2006
    Messages:
    896
    Location:
    North Carolina, USA
    Country:
    United States
    Swing is for Java, not JavaScript. I'd be able to help you if it was JavaScript, but I don't know any Java.
     
  3. DarkSpace
    OP

    Member DarkSpace Custom member title

    Joined:
    Aug 23, 2007
    Messages:
    551
    Country:
    United States
    Is there someway that a class file could be put into the webpage? I'm supposed to use jcreator to make it. Maybe I mixing up something. I'm not really sure.
     
  4. chuckstudios

    Member chuckstudios Putting the pro in procrastination

    Joined:
    Jul 19, 2006
    Messages:
    896
    Location:
    North Carolina, USA
    Country:
    United States
  5. Psyfira

    Member Psyfira Credit: 0ml. Insert tea to continue

    Joined:
    Dec 31, 2003
    Messages:
    3,887
    Location:
    England
    Country:
    United Kingdom
    If we're talking standard Java, there are several different types of dialog box you can use. One of them (JOptionPane) automatically returns anything typed into the box as a string value. You then have to convert the string to a number to use it in equations.

    There are examples of how to use the JOption box in the Java API (if you've never used this page before it's the giant index to life, the universe and all the built-in objects and functions in the Java library. Bookmark it now. Just find JOptionPane in the menu on the left)

    And if that's all a bit confusing, Sun's Dialog Box Tutorial explains it a bit better [​IMG]

    So now we have what the user typed as a string. All that's left to do is to convert the string to a number.
     

Share This Page