Need help with some basic programming in Javascript

  • Thread starter Thread starter DarkSpace
  • Start date Start date
  • Views Views 1,589
  • Replies Replies 4

DarkSpace

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