HTML 2일차 prompt 연습

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>JSP Test</title>
</head>
<body>
<script LANGUAGE="JavaScript">
function getint()
{
return Math.floor(Math.random() * 10);
}

while(true)
{
str = getint()+" * "+getint();
ans = prompt(str+" = 식의 정답을 입력하세요.", "");
if(ans == "")
{
ask = confirm("종료하시겠습니까?");
if(ask==true)
break;
}
res = eval(str);
if(res == ans)
{
var ask = confirm("정답입니다.\n계속 하시겠습니까?");
if (ask == false)
break;
}
else if(res != ans)
{
var ask = confirm("오답입니다. 정답은 " + res + "입니다.");
if (ask == false)
break;
}
}
</script>
</body>
</html>


result)






댓글 없음: