Forum : LOOPS
Brief description  about Online courses   join in Online courses
View nishant  gaurav 's Profile

LOOPS

<html>
<form name=frm>
number is:<input type="text" name="num" size=5 value="" >
</form>
<head>
<script type="text/javascript">
A=eval(document.frm.num.value);
for(i=0;i<=100;i )
{
if (i == A)
{
break;
}
document.write("the loop ran" i" times.");
}
</script>
</head>
</html>
TELL ME WHATS WRONG WITH IT
Asked by nishant gaurav | Sep 1, 2010 |  Reply now
Replies (2)
View anonymous anonymouse 's Profile
How can eval have a return type.?
Sep 3, 2010
View teacher siliconindia 's Profile
Hi Nishant,

U completed HTML course, but u included form tag inside head section.. i don't know y...?

where u are calling JS function in the above code.. 'for' loop syntax wrong..

concentrate on course buddy,

check the code below,

function Module11()
{
num = document.myform5.field1.value;
value=0;

if((num == 0) || (num > 100))
{
alert("Please Enter Number Between 1 - 100");
}
else
{
for(i=1 ; i<=100 ; i++)
{
document.write(i+"<br />");
if(i == num)
break;
}
document.write("<br />Loop Ended At User Given Value i.e. '"+num+" '");
}
}
Sep 3, 2010