Need help with some basic programming in Javascript

DarkSpace

Custom member title
OP
Member
Joined
Aug 23, 2007
Messages
551
Trophies
0
Website
Visit site
XP
187
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.
 

DarkSpace

Custom member title
OP
Member
Joined
Aug 23, 2007
Messages
551
Trophies
0
Website
Visit site
XP
187
Country
United States
chuckstudios said:
Swing is for Java, not JavaScript. I'd be able to help you if it was JavaScript, but I don't know any Java.

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.
 

Psyfira

Credit: 0ml. Insert tea to continue
Member
Joined
Dec 31, 2003
Messages
3,886
Trophies
0
Location
England
XP
270
Country
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
smile.gif


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.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Xdqwerty @ Xdqwerty: good night