Printing 99 multiplication table code with JSP / JavaScript

Time:2021-4-2

JSP expression mode

Copy codeThe code is as follows:
<center>
<table border=”1″>
<%
for (int i = 1; i <= 9; i++) {
%>
<tr>
<%
for (int j = 1; j <= 9; j++) {
%>
<td>
<%
if (j <= i) {
%> <%=i%>*<%=i%>=<%=i * j%> <%
} else
%> &nbsp;
</td>
<%
}
%>
</tr>
<%
}
%>
</table>
</center>

JavaScript mode

Copy codeThe code is as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8″>
< title > 99 multiplication table
<script type=”text/javascript”>
document.write(“<center><table border=\”3\”>”);
for (i = 1; i <= 9; i++) {
document.write(“<tr>”);
for (j = 1; j <= 9; j++) {
if (j <= i) {
document.write(“<td>” + i + “*” + j + “=” + i * j + “</td>”)
} else
document.write(“<td>&nbsp;</td>”);
}
document.write(“</tr>”);
}
document.write(“</table></center>”);
</script>
</head>
<body>
</body>
</html>

Recommended Today

Review of SQL Sever basic command

catalogue preface Installation of virtual machine Commands and operations Basic command syntax Case sensitive SQL keyword and function name Column and Index Names alias Too long to see? Space Database connection Connection of SSMS Connection of command line Database operation establish delete constraint integrity constraint Common constraints NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY DEFAULT […]