Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,100 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,658 people online right now. Registration is fast and FREE... Join Now!




java script

 
Reply to this topicStart new topic

java script, unknown mistake...

Doka
13 Nov, 2007 - 04:37 AM
Post #1

New D.I.C Head
*

Joined: 28 Jun, 2007
Posts: 22


My Contributions
hey I have been trying to fix this piece of code to work but I get an error saying ( ; ) missing? I am sure its not that, have a look:
CODE
<html>
<head>
<script type="text/javascript">
<!--
var n;  
var num;
for (int i=0; i<=5; i++){
n=window.prompt("Enter a number: " , "0");
num=parseInt(n);
var max=num;
var min=num;
if (min>=num)
min=num;
else
max=num;
}
document.writeln("<h1>Max: " + max +"</h1>");
document.writeln("<h1>Min: " + min +"</h1>");
//-->
</script>
</head>
<body>
</body>
</html>


That code should accept 5 integers from user and return he maximum and minimum value, so whats the mistake?

This post has been edited by Doka: 13 Nov, 2007 - 05:10 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Java Script
13 Nov, 2007 - 04:57 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8600
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
What does it say is missing, all we see is smile.gif missing
User is offlineProfile CardPM
+Quote Post

Doka
RE: Java Script
13 Nov, 2007 - 05:15 AM
Post #3

New D.I.C Head
*

Joined: 28 Jun, 2007
Posts: 22


My Contributions
QUOTE(PsychoCoder @ 13 Nov, 2007 - 05:57 AM) *

What does it say is missing, all we see is smile.gif missing


haha I fixed it, it was a semicolon
User is offlineProfile CardPM
+Quote Post

Sun Rise
RE: Java Script
13 Nov, 2007 - 07:17 AM
Post #4

New D.I.C Head
*

Joined: 27 Jun, 2007
Posts: 7


My Contributions
var n;
var num=0;
var max=0;
var min=0;
max=num;
min=num;
for (var i=0; i<5; i++){
n=window.prompt("Enter a number: " , "0");
num=parseInt(n);
if (min>=num)
min=num;
else
max=num;

}
document.writeln("<h1>Max: " + max +"</h1>");
document.writeln("<h1>Min: " + min +"</h1>");
//-->
</script>

User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Java Script
13 Nov, 2007 - 07:45 AM
Post #5

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 3,984



Thanked: 16 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
moved to javascript

[EDIT]ya beat me Sun Rise![/EDIT]
your for loop assigns as an int, where it should be var.
User is offlineProfile CardPM
+Quote Post

Doka
RE: Java Script
14 Nov, 2007 - 07:01 AM
Post #6

New D.I.C Head
*

Joined: 28 Jun, 2007
Posts: 22


My Contributions
yes thanks, Sun Rise, you are the best wink2.gif
thanks William, I didnt really know there was a javascript section, sorry rolleyes.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:50PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month