我这里不加<form>也能实现效果,那实际编程里<form>的作用和应用场景是什么?

来源:5-9 编程练习

ZZ6459418

2022-06-29 11:15:09

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>try</title>
</head>
<body>
	<table >
		<caption><font size="5">注册信息</font></caption>
		<tr>
			<th>用户名:</th><br>
			<th> <input type="text" name="" placeholder="请输入用户名"></th><br>
		</tr>
		<tr>
			<th>密码:</th><br>
			<th> <input type="password" name="" placeholder="请输入密码"></th><br>
		</tr>
		<tr>
			<th>确认密码:</th><br>
			<th> <input type="password" name="" placeholder="请确认密码"></th><br>
		</tr>
		<tr>
			<th>上传照片:</th>
			<th><input type="file" name="" 未选择文件></th>
		</tr>
	</table>
</body>
</html>


写回答

1回答

好帮手慕小蓝

2022-06-29

同学你好,在后面学习servlet之后,我们会将前端的数据向Java代码进行传递。此时如果不使用form表单,每一个input的数据无法直接向java代码进行传递,此时如果需要将数据进行传递,就必须使用form表单了。

因为form表单的标签属性中可以配置action等属性,并且可以配合submit按钮,实现对数据进行传递。

祝学习愉快~

0

0 学习 · 16556 问题

查看课程