Thursday, 6 May 2021

(JAVASCRIPT) Tạo 1 bảng gồm n dòng n cột do người nhập // Vòng lặp for

Untitled Document //Tạo 1 bảng gồm n dòng n cột do người nhập // Vòng lặp for

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<script type="text/x-javascript">
    //Tạo 1 bảng gồm n dòng n cột do người nhập
m=parseInt(prompt("Nhập số dòng: ",""));
n=parseInt(prompt("Nhập số cột: ",""));
document.write("<table border='1' width=60%>")
for(i=1;i<=m;i++)
{
document.write("<tr>&nbsp;</tr>")
for(j=1;j<=n;j++)
document.write("<td>&nbsp;</td>")
}
document.write("</table>")
    </script>
</body>
</html>

0 comments:

Post a Comment