JavaScript DHTML/Language Basics/do while — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 07:24, 26 мая 2010
Combine do-while loop and prompt dialog to read user input
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
do
{
sometext = prompt("Enter some text","");
}
while (sometext == "");
alert(sometext);
</script>
</head>
<body>
</body>
</html>
Use do-while loop and prompt dialog to restrict user input
<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
do {
sometext = prompt("Enter some text","Type some text");
}
while (sometext == "Type some text" || sometext == "" || sometext == null);
alert(sometext);
</script>
</head>
<body>
</body>
</html>