오늘은 며칠 전에 공부하고 블로그 작성 못한
HTML의 입력양식(form)에 대해 복습 겸 포스팅을 해본다.
< form >는 아래 두가지와 함께 공급되어야 한다.
-> 각각 action, method의 속성에 담긴다.
<form action="/example.html" method="POST">
</form>
어떤 방식으로 전달할 것인가?
method 속성은 속성값으로는 GET과 POST 두 가지 중 하나를 선택
- get : URL에 폼 데이터를 추가하여 서버로 전달하는 방식 (길이에 제한이 있어 보안에 취약)
- post : 폼 데이터를 별도로 첨부하여 서버로 전달하는 방식(길이에 제한없음, 중요한 정보는 post로)
<form action="/example.html" method="POST">
<h1>Creating a form</h1>
<p>Looks like you want to learn how to create an HTML form.
Well, the best way to learn is to play around with it.</p>
</form>
<form action="/example.html" method="POST">
<input type="text" name="first-text-field"
value="already pre-filled"> //no closing tag
</form>
<form>
<label for="user-password">Password: </label>
<input type="password" id="user-password" name="user-password">
</form>
<form>
<label for="years"> Years of experience: </label>
<input id="years" name="years" type="number" step="1">
</form>
<form>
<label for="volume"> Volume Control</label>
<input id="volume" name="volume" type="range" min="0" max="100" step="1">
</form>
<form>
<p>Choose your pizza toppings:</p>
<label for="cheese">Extra cheese</label>
<input id="cheese" name="topping" type="checkbox" value="cheese">
<br>
<label for="pepperoni">Pepperoni</label>
<input id="pepperoni" name="topping" type="checkbox" value="pepperoni">
<br>
<label for="anchovy">Anchovy</label>
<input id="anchovy" name="topping" type="checkbox" value="anchovy">
</form>
<form>
<p>What is sum of 1 + 1?</p>
<input type="radio" id="two" name="answer" value="2">
<label for="two">2</label>
<br>
<input type="radio" id="eleven" name="answer" value="11">
<label for="eleven">11</label>
</form>
<form>
<label for="city">Ideal city to visit?</label>
<input type="text" list="cities" id="city" name="city">
<datalist id="cities">
<option value="New York City"></option>
<option value="Tokyo"></option>
<option value="Barcelona"></option>
<option value="Mexico City"></option>
<option value="Melbourne"></option>
<option value="Other"></option>
</datalist>
</form>
<form>
<input type="submit" value="Send">
</form>
<form>
<label for="lunch">What's for lunch?</label>
<select id="lunch" name="lunch">
<option value="pizza">Pizza</option>
<option value="curry">Curry</option>
<option value="salad">Salad</option>
<option value="ramen">Ramen</option>
<option value="tacos">Tacos</option>
</select>
</form>
<form>
<label for="blog">New Blog Post: </label>
<br>
<textarea id="blog" name="blog" rows="5" cols="30">
</textarea>
</form>
오늘의 퇴근 후 코딩공부 끝!