次の属性を持つ 2 つの Web ページを作成する必要があります。
- フォーム (これが html または jsp ファイルのどちらであるかを決定します)。
フォームには、テキスト入力 (「サイズ」と呼ばれる) とボタンの 2 つのフィールドを持つ HTML フォームが含まれています。
ボタンをクリックすると、別のページが表示されます。
- テーブル (HTML か JSP かを決定)
テーブルは、前ページの「サイズ」までの乗算テーブルを示します。
例:
3 がクリックされた場合、出力は次のようになります。
1 2 3
2 4 6
3 6 9
また、ボタンをテーブルに追加して、このボタンを押すとテーブルが消えるようにします。
ここに私のフォームコードがあります
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>
<h1>multiplication table</h1>
<form action="form_action.jsp" method="get">
Size: <input type="size" name="size" size="35" /><br />
<input type="submit" value="Submit" />
</form>
<p>Click on the submit button, and the input will be sent to a page
on the server called "form_action.jsp".</p>
</body>
</html>
および乗算表を生成する私のページ
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<head>
<title>Calculation from a form</title>
</head>
<body>
<div>Calculation</div>
<table border="Calculation">
<%
String temp = request.getParameter("number");
int x = Integer.parseInt(temp);
String table = "<table border='1' id='mytable'>";
for (int row = 1; row < 11; row++) {
%>
<tr>
<%
for (int column = 1; column < 11; column++) {
%>
<td><tt><%=row * column%></tt></td>
<%
}
%>
</tr>
<%
}
%>
</table>
</body>
これを始めるのを手伝ってくれる人はいますか?