Form : 사용자에게 정보를 입력받는 요소(element)
<form> <input> </form>
<body>
<form>
<input type="text" name="search">
<input type="submit">
</form>
</body>
<form action="전송 위치" method="전송 방식>GET (default) : 주소에 데이터 직접 입력, 전달POST : 별도의 방법을 사용해 데이터를 해당 주소로 전달<!-- GET -->
<body>
<form method="get">
<input type="text" name="search">
<input type="submit">
</form>
</body>
<!-- POST -->
<body>
<form method="post">
<input type="text" name="search">
<input type="submit">
</form>
</body>
* text* password* file* checkbox* radio* hidden* button* reset* submit* image· radio의 name 속성 사용
· name 값을 동일하게 해야 같은 그룹으로 묶임
남자
여자<input type="radio" id="man" name="gender"> <label for="man">남자</label> <input type="radio" id="woman" name="gender"> <label for="woman">여자</label>```
<form>
<input type="checkbox" id="agreement" />
<label for="agreement">여기 텍스트를 눌러도 체크된다</label>
</form>
여기 텍스트를 눌러도 체크된다
(이렇게 써도 됨~)
<label>
<input type="checkbox" id="agreement"/>
여기 텍스트를 눌러도 체크된다
</label>
여기 텍스트를 눌러도 체크된다
<select>
· 목록 중 하나 또는 여러 개 선택할 때 사용
· option / optgroup 태그와 함께 사용
한 항목 선택 - option
<form>
<select>
<option>김밥</option>
<option>떡볶이</option>
<option>순대</option>
<option>어묵</option>
</select>
<input type="submit">
</form>
김밥
떡볶이
순대
어묵
여러 항목 선택 - multiple
<form>
<!-- 그냥 multiple만 써도 됨 -->
<select multiple="multiple">
<option>김밥</option>
<option>떡볶이</option>
<option>순대</option>
<option>어묵</option>
</select>
<input type="submit">
</form>
김밥
떡볶이
순대
어묵
선택 옵션 묶기 - optgroup
<form>
<select>
<optgroup label="분식">
<option>김밥</option>
<option>떡볶이</option>
<option>오뎅</option>
</optgroup>
<optgroup label="한식">
<option>김치찌개</option>
<option>된장찌개</option>
<option>칼국수</option>
</optgroup>
</select>
</form>
김밥
떡볶이
오뎅
김치찌개
된장찌개
칼국수
<form>
<fieldset>
<legend>타이틀</legend>
<table>
<tr>
<th>이름</th>
<td>
<input type="text" name="text" />
</td>
</tr>
<tr>
<th>이메일</th>
<td>
<input type="email" name="email" />
</td>
</tr>
</table>
<input type="submit" value="제출" />
</fieldset>
</form>
타이틀
| 이름 | |
|---|---|
| 이메일 |
: 여러 줄을 입력 받는 요소
<textarea> 속성 종류
* cols : 너비
* rows : 높이
주의 사항
- 엔터, 탭, 스페이스가 그대로 출력 됨
<form>
<textarea cols="40" rows="5">
올바른 형태
</textarea>
<textarea cols="40" rows="5">
잘못된 형태
</textarea>
</form>