4-4. html form์˜ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ํƒœ๊ทธ ๊ณผ ๊ธฐ์ดˆ ์—ฐ์Šต ๋ฌธ์ œ

2021. 10. 9. 20:04ใ†HTML + CSS + JS

728x90

1. <textarea>..</textarea>

<textarea> : ํ…์ŠคํŠธ๋ฅผ ์—ฌ๋Ÿฌ ์ค„ ์ž…๋ ฅํ•˜๋Š” ์˜์—ญ์„ ๋งŒ๋“ ๋‹ค. 

 

<textarea> ์†์„ฑ 

1๏ธโƒฃ cols : ํ…์ŠคํŠธ ์˜์—ญ์˜ ๊ฐ€๋กœ ๋„ˆ๋น„๋ฅผ ๋ฌธ์ž ๋‹จ์œ„๋กœ ์ง€์ •ํ•œ๋‹ค. 

2๏ธโƒฃ rows : ํ…์ŠคํŠธ ์˜์—ญ์˜ ์„ธ๋กœ ๊ธธ์ด๋ฅผ ์ค„ ๋‹จ์œ„๋กœ ์ง€์ •ํ•œ๋‹ค. 

 

2. <select>..</select>, <option>..</option>

์‚ฌ์šฉ์ž๊ฐ€ ๋‚ด์šฉ์„ ์ง์ ‘ ์ž…๋ ฅํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์—ฌ๋Ÿฌ ์˜ต์…˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

<select>

   <option> ..</option>

</select>

 

<select> ์†์„ฑ 

1๏ธโƒฃ size : ํ™”๋ฉด์— ํ‘œ์‹œํ•  ๋“œ๋กญ๋‹ค์šด ํ•ญ๋ชฉ์˜ ๊ฐœ์ˆ˜๋ฅผ ์ง€์ •ํ•œ๋‹ค. 

2๏ธโƒฃ multiple : ๋“œ๋กญ๋‹ค์šด ๋ชฉ๋ก์—์„œ ๋‘˜ ์ด์ƒ์˜ ํ•ญ๋ชฉ์„ ์„ ํƒํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. 

 

<option> ์†์„ฑ

1๏ธโƒฃ value : ํ•ด๋‹น ํ•ญ๋ชฉ์„ ์„ ํƒํ•  ๋•Œ ์„œ๋ฒ„๋กœ ๋„˜๊ฒจ์ค„ ๊ฐ’์„ ์ง€์ •ํ•œ๋‹ค. 

2๏ธโƒฃ selected : ๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด๋ฅผ ์‚ฝ์ž…ํ•  ๋•Œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์„ ํƒํ•ด์„œ ๋ณด์—ฌ์ค„ ํ•ญ๋ชฉ์„ ์ง€์ •ํ•œ๋‹ค. 

 

 

* ์—ฐ์Šต ๋ฌธ์ œ 1 

 

๊ฒฐ๊ณผ html

 

<!DOCTYPE html>
<html lang="ko">
<head>
	<meta charset="UTF-8">
	<title>์—ฐ์Šต๋ฌธ์ œ 1</title>
	<style>
		ul {
			list-style:none;
		}
		li {
			line-height:50px;
		}
		label {
			width:60px;
			float:left;
		}
	</style>
</head>
<body>
	<h1>์˜ˆ์•ฝ ์ •๋ณด</h1>
 
	<form>
		<ul>
			<li>
				<label for="user_name">์ด ๋ฆ„</label>
				<input type="text" id="user_name">
			</li>

			<li>
				<label for="user_tel">ํœด๋Œ€ํฐ</label>
				<input type="tel" id = "user_tel">
			</li>

			<li>
				<label for="user_email">์ด๋ฉ”์ผ</label>
				<input type="email" id = "user_email">
			</li>
			<li>
				
	<input type="submit" value="์˜ˆ์•ฝํ•˜๊ธฐ">
			</li>
		</ul>
	</form>
</body>
</html>

 

* ์—ฐ์Šต๋ฌธ์ œ 2

์‹คํ–‰ ๊ฒฐ๊ณผ

<!DOCTYPE html>
<html lang="ko">
  <head>
    <meta charset="UTF-8">
    <title>์—ฐ์Šต๋ฌธ์ œ 2</title>
    <style>
			#container { 
				width:520px;
				border:1px solid black;
				padding:20px 40px;
				margin:0 auto;
			}
      fieldset { margin-bottom:15px; }
      legend { font-weight:bold; }
			ul {list-style-type: none;}
			li { line-height:30px;}
    </style>
  </head>
  <body>
		<div id="container">
			<h1>ํ”„๋ŸฐํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž ์ง€์›์„œ </h1>
			<p>HTML, CSS, Javascript์— ๋Œ€ํ•œ ๊ธฐ์ˆ ์  ์ดํ•ด์™€ ๊ฒฝํ—˜์ด ์žˆ๋Š” ๋ถ„์„ ์ฐพ์Šต๋‹ˆ๋‹ค.</p>
			<hr>
			<form>
				<h4>๊ฐœ์ธ์ •๋ณด</h4>
				<ul>
					<li>
						<label for="user_name">์ด๋ฆ„</label>
						<input type="text" id="user_name" placeholder="๊ณต๋ฐฑ์—†์ด ์ž…๋ ฅํ•˜์„ธ์š”" autofocus>
					</li>

					<li>
						<label for="user_tel">์—ฐ๋ฝ์ฒ˜</label>
						<input type="tel" id="user_tel">
					</li>
				</ul>

				<h4>์ง€์› ๋ถ„์•ผ</h4>
				<ul>
					<li>
						<label><input type="radio" name="field" value="publishing"> ์›น ํผ๋ธ”๋ฆฌ์‹ฑ</label>
					</li>
					<li>
						<label><input type="radio" name="field" value="develop"> ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ</label>
					</li>
					<li>
						<label><input type="radio" name="field" value="envi"> ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ฐœ์„ </label>
					</li>
				</ul>

				<h4>์ง€์›๋™๊ธฐ</h4>
				<textarea cols="60" rows="5" placeholder="๋ณธ์‚ฌ ์ง€์› ๋™๊ธฐ๋ฅผ ๊ฐ„๋žตํžˆ ์จ ์ฃผ์„ธ์š”."></textarea>

				<div>
					<input type="submit" value="์ ‘์ˆ˜ํ•˜๊ธฐ">
					<input type="reset" value="๋‹ค์‹œ ์“ฐ๊ธฐ">
				</div>
			</form>
		</div>
  </body>
</html>

 

 

728x90