html08

제로·2022년 11월 3일
0

HTML

목록 보기
8/13

form 작성

  1. form 태그 기본 형식
<form name="fo" method="get" action="페이지">
		<input type="submit">
	</form>
  1. 속성
    1) name : 폼의 이름을 지정
    2) action :
    - 폼 데이터를 처리할 웹 서버 응용프로그램(jsp, php, asp등)을 통해 요청값을 서버단(백엔드)에서 받을 수 있다.
    - submit 버튼을 클릭하면 브라우저는 action에 지정한 웹 서버 응용프로그램을 실행한다.
    3) method : 폼 데이터를 웹 서버로 전송하는 방식
    - get : 설정하지 않으면 default로 설정되는 방식으로 url 주소 창에 요청값을 key=value 형식으로 보이게한다.
    - post : 설정을 하면 url 주소창에는 보이지 않지만 내부적으로 요청 값을 key=value 형식으로 전송한다.
    4) target :
    - frame 단위나 새로운 윈도우 창에 전송할 때, frame 처리시 설정했던 옵션을 활용해서 처리한다. (_top, _parent, _blank, _self, 프레임명)
    5) enctype
    - 폼 데이터를 웹서버로 전송할 때, 양호화 방식이 필요한 경우에 사용된다.
    method가 post일 때 사용가능하다.
<h3>예재</h3>
 	<form action="a06_rev.jsp" method="post" target="frame01">
 		물건명 : <input type="text" name="pname"><br>
 		가격 : <input type="text" name="price"><br>
 		<input type="submit" value="물건등록"><br><br>
 	</form>
    
 	<iframe name="frame01" 
 	srcdoc="<html><h3>여기에 물품 정보 출력</h3></html>" 
 	width="50%" height="100"></iframe>


 <h3>로그인(예재)</h3>
 	 <form action="a07_loginResult.jsp" method="post" target="frame02">
 		 아 이 디 : <input type="text" name="id"><br>
 		 비밀번호 : <input type="password" name="pass"><br>
 		 <input type= "submit" value="로그인"><br><br>
 	 </form>
 	
 	 <iframe name="frame02" width="20%" height="120" 
 	 srcdoc="<h3>로그인 결과</h3>"></iframe>
     
## a07_loginResult.jsp
<h5>아이디 : ${param.id }<br> 비밀번호 : ${param.pass } </h5>
<h5> ${param.id=='himan' and param.pass=='7777'?'로그인성공':'로그인실패' }</h5>


## jsp 파일 내에서
	 <h3>로그인</h3>
 	 <form  method="post">
 		 아 이 디 : <input type="text" name="id"><br>
 		 비밀번호 : <input type="password" name="pass"><br>
 	 	<input type= "submit" value="로그인"><br><br>
 	 </form>
     
 	 <h3>로그인 결과</h3>
 	 <h4>아이디:${param.id }</h4>
 	 <h4>비밀번호:${param.pass }</h4>
 	 <h4>${param.id=='himan' and param.pass=='7777'?'로그인성공':'로그인실패' }</h4>


profile
아자아자 화이팅

0개의 댓글

관련 채용 정보