RSS Forums RSS
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 740 | Replies: 3
Reply
Join Date: Aug 2006
Posts: 32
Reputation: desiguru is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
desiguru desiguru is offline Offline
Light Poster

Help Can someone help me here.

  #1  
Apr 23rd, 2007
I cant find a good solution for my fist java script class. Can someone help me here. The result is not showing up here.

  1. <script language = "JavaScript">
  2. document.write('<center><h3>-- Myname 23 -- ')
  3. myDate = new Date ();
  4. document.write(myDate.toLocaleString());
  5. document.write('</h3></center><hr>');
  6.  
  7. </script>
  8.  
  9. <script language = "JavaScript">
  10.  
  11. // Add, subtract, multiply, and divide
  12. var firstvar;
  13. var secondvar;
  14. var resultvar;
  15.  
  16. // Add 23.5 and 15
  17.  
  18. document.write ('adding 23.5 and 15
  19.  
  20. ');
  21. firstvar=23.5;
  22. secondvar=15;
  23. resultvar
  24.  
  25. document.write(firstvar);
  26. document.write('
  27. ');
  28.  
  29. document.write(secondvar);
  30. document.write('
  31. ');
  32.  
  33. document write('---');
  34. document.write('
  35. ');
  36.  
  37. resultvar = firstvar + secondvar;
  38. document.write(resultvar);
  39. document.write('
  40.  
  41. ');
  42.  
  43. // Subtract 45 from 10
  44.  
  45. document.write ('subtracting 45 from 10
  46.  
  47. ');
  48. firstvar=10;
  49. secondvar=45;
  50.  
  51. document.write(firstvar);
  52. document.write('
  53. ');
  54.  
  55. document.write(secondvar);
  56. document.write('
  57. ');
  58.  
  59. document.write('---');
  60. document.write('
  61. ');
  62.  
  63. resultvar= firstvar - secondvar;
  64. document.write(resultvar);
  65. document.write('
  66.  
  67. ')
  68.  
  69. // Multiply 2.5 by 15
  70.  
  71. document.write ('multiplying 2.5 by 15
  72.  
  73. ')
  74. firstvar=2.5
  75. secondvar=15
  76.  
  77. document.write(firstvar);
  78. document.write('
  79. ');
  80.  
  81. document.write(secondvar);
  82. document.write('
  83. ');
  84.  
  85. document.write('---');
  86. document.write('
  87. ');
  88.  
  89. resultvar= firstvar * secondvar;
  90. document.write(resultvar);
  91. document.write('
  92.  
  93. ');
  94.  
  95. // Divide 144 by 12
  96.  
  97. document.write ('dividing 144 by 12
  98.  
  99. ');
  100. firstvar=144;
  101. secondvar=12;
  102.  
  103. document.write(firstvar);
  104. document.write('
  105. ');
  106.  
  107. document.write(secondvar);
  108. document.write('
  109. ');
  110.  
  111. document.write('---');
  112. document.write('
  113. ');
  114.  
  115. resultvar= firstvar / secondvar;
  116. document.write(resultvar);
  117. document.write('
  118.  
  119. ');
  120. </script>
--
DG
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,556
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 11
Solved Threads: 144
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: Can someone help me here.

  #2  
Apr 23rd, 2007
I'm sorry, but this ia a Java forum. JavaScript != Java. Please get this moved to a JavaScript forum.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Aug 2006
Posts: 32
Reputation: desiguru is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
desiguru desiguru is offline Offline
Light Poster

Re: Can someone help me here.

  #3  
Apr 24th, 2007
Aneone here who can help me out on this problem?
--
DG
Reply With Quote  
Join Date: Jan 2007
Posts: 2,640
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 118
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: Can someone help me here.

  #4  
Apr 24th, 2007
This is the HTML, CSS, and JavaScript forum.

How are you calling the JavaScript from your html code? It doesn't just run itself.

Either your main JavaScript code must be in the body portion of the code, or you must use an on-action attribute in an html tag to cause a function to be called when the specified action occurs.


Also, I see some errors in your code. Errors cause the JavaScript interpreter to quit running.

The errors:

Line 1: The language attribute is nonstandard. Use type="text/javascript" instead.

Line 2: Missing ending ;

Lines 7-9: Only one main program is allowed in an html file. Which set runs depends on the browser.

Line 18: Incomplete statement (you can't start a quote on one line and end it on another - note that if the listing program you used to put this page here is rendering \n as a real newline instead of printing the characters, these are not errors).

This also happens in lines:
23, 26, 30, 34, 39, 45, 52, 56, 60, 65, 71, 78, 82, 86, 91, 97, 104, 108, 112, and 117.
Last edited by MidiMagic : Apr 24th, 2007 at 3:53 am. Reason: scripy
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:23 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC