Difference between revisions of "JavaScript: Exemplo de uso do for"

From AdonaiMedrado.Pro.Br
Jump to: navigation, search
(New page: <code language="html"> <html> <head> <title>Minha Pagina</title> </head> <body> <script> var i = 0; while(i<10) { document.write("<input type=\"text\" id=\"txtTeste" + i + "...)
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<code language="html">
+
<code lang="javascript">
 
<html>
 
<html>
 
<head>
 
<head>
<title>Minha Pagina</title>
+
<title>Minha Página</title>
 
</head>
 
</head>
 
<body>
 
<body>
 
<script>
 
<script>
var i = 0;
+
var i;
while(i<10)
+
for (i=0;i<10;i++)
{
+
alert("Eu sou a caixa chata " + (i + 1));
document.write("<input type=\"text\" id=\"txtTeste" + i + "\"" + ">");
+
document.write("<input type=\"button\" id=\"btOK" + i + "\"" + " value=\"OK\">");
+
document.write("<br />");
+
msg = prompt("Digite seu texto.","Seu texto");
+
document.getElementById("txtTeste" + i).value = msg;
+
i++;
+
}
+
 
</script>
 
</script>
 
</body>
 
</body>
 
</html>
 
</html>
 
</code>
 
</code>

Latest revision as of 22:30, 12 September 2008

<html>
	<head>
		<title>Minha Página</title>
	</head>
	<body>
	<script>
		var i;
		for (i=0;i<10;i++)
			alert("Eu sou a caixa chata " + (i + 1));
	</script>
	</body>
</html>