본문 바로가기

IT Study/Web

[HTML] form 기본 예제


form

다른 페이지로 값을 넘길때 사용하는 기본적인 태그



HTML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
 
<form action="">
ID:
<input type="text" name="userid" readonly="readonly" value="abc">
<br>
PASSWORD:
<input type="password" name="pass" >
<br>
<input type="submit" value="로그인">
<input type="reset" value="초기화">
</form>
 
<!-- checkbox -->
<form action="NewFile2.jsp">
 
<input type="checkbox" name="interest" value="1">패션
<input type="checkbox" name="interest" value="2">음악
<input type="checkbox" name="interest" value="3">게임
 
<input type="submit" value="버튼">
</form>
 
<form action="NewFile3.jsp">
<input type="radio" name="car" value="벤츠" checked="checked">벤츠
<br>
<input type="radio" name="car" value="아우디">아우디
<br>
<input type="radio" name="car" value="BMW">BMW
<br>
<input type="radio" name="car" value="람보르기니">람보르기니
<br>
<input type="submit" value="버튼">
<br>
 
</form>
 
</body>
</html>
cs


NewFile3.jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
 
<%
 
 
String car = request.getParameter("car");
 
System.out.println(car);
 
%>
</body>
</html>
cs


'IT Study > Web' 카테고리의 다른 글

[HTML] 영상(video) 출력  (0) 2018.08.06
[HTML] 경도,위도 구하기  (0) 2018.08.06
[HTML] iframe  (0) 2018.08.06
[HTML] CSS 적용방법 3가지  (0) 2018.08.06
[HTML] List 종류  (0) 2018.08.06