Lesson 10 · 17 steps
controls.html is where the site stops being something to read and starts being something to use: buttons, a text box, checkboxes, a grouped list, a slider, a colour picker. Also the only line of JavaScript in the whole practicum.
<!-- 2) кнопка, яка веде на іншу сторінку --> <h2> Кнопка </h2> <input type="button" value="На другу сторінку" onClick='location.href="controls1.html"'>
A button on its own does nothing at all — it needs to be told what happens on a click. onClick holds a line of JavaScript, and location.href is the browser's address bar: assign to it and the page changes.
This is the first and only script in the whole practicum, and it is one line.
Code written inside an attribute is awkward to maintain and is blocked by the security policies most sites set these days. The same button today is a link styled as a button, or a real <button> with its handler attached in a separate script file.
<!-- 3) кнопка-зображення --> <h2> Кнопка-зображення <input> </h2> <a href="controls1.html"> <input type="image" src="im/button.png" alt="Кнопка з малюнком"> </a>
type="image" turns a picture into a submit button. The picture is im/button.png — drawn for this site rather than taken from somewhere.
<!-- 5) посилання, оформлене як кнопка -->
<style type="text/css">
.new1 {border:1px solid #f0a500;background:#3a2a1a;color:#f0a500;text-decoration:none;padding:6px 14px}
<!-- 5) посилання у вигляді кнопки --> <h2> Посилання, схоже на кнопку </h2> <a class="new1" href="controls1.html"> Кнопка </a>
A border, a background and text-decoration:none, and a link looks exactly like a button. The difference is underneath: a link navigates, a button acts, and the browser treats them differently for the keyboard and for opening in a new tab.
Choosing between them is a real decision, not a matter of taste: if the result is «I am now on a different page», it is a link. If it is «something happened right here», it is a button.
<!-- 4) кнопка переходу формою, метод GET --> <h2> Перехід формою </h2> <form method="GET" action="controls1.html"> <input type="submit" value="Перейти формою"> </form>
A form with method="GET" and nothing to fill in is a button that leads to a page. The method matters later, when there is something to send.
The LINK method in the assignment's sample is not a real HTTP method — no browser has ever implemented it. GET is used here instead, which does the same thing and actually works.
<!-- 6) текстове поле, метод POST --> <h2> Текстове поле </h2> <form method="GET" action="sent.html"> <p> Розкажіть про свій найкращий раунд: </p> <textarea name="story" cols="50" rows="6"></textarea><br> <input type="submit" value=" Надіслати "> </form>
textarea is a multi-line field; cols and rows set its size in characters and lines. The name is the label the answer travels under.
The form points at sent.html, because this site has no server to receive anything. Submitting it shows what the browser sent — visible in the address bar, since the method is GET.
That is exactly the difference between the two methods: GET puts the answers in the address, POST sends them in the body of the request where they are not visible. Neither is secret — only HTTPS makes it private — but a password in the address bar would end up in the history, in logs and in bookmarks.
<!-- 7) прапорці --> <h2> Прапорці </h2> <form method="GET" action="sent.html"> <input type="checkbox" name="dust2" checked> Ви грали на Dust II?<br> <input type="checkbox" name="mirage" checked> Ви грали на Mirage?<br> <input type="checkbox" name="nuke"> Ви грали на Nuke?<br> <input type="checkbox" name="ancient"> Ви грали на Ancient?<br> <input type="submit" value=" Надіслати "> </form>
Each checkbox is independent, so they all need different names. checked ticks one from the start.
Clicking the text should toggle the box, and here it does not. The fix is <label> around both, which also gives screen readers the question that belongs to the box.
<!-- 9) перемикачі --> <h2> Перемикач </h2> <form method="GET" action="sent.html"> <p> Скільки років ви граєте? </p> <input type="radio" name="years" value="1"> менше року <input type="radio" name="years" value="2"> рік <input type="radio" name="years" value="3" checked> два-три <input type="radio" name="years" value="4"> більше п'яти <br> <input type="submit" value=" Надіслати "> </form>
Radio buttons work the opposite way: the same name on all of them is what makes them one group, and picking one releases the others. A different name on each would give four independent switches.
<!-- 10) список із прокруткою, розбитий на групи -->
<h2> Список із групами </h2>
<select name="mylist" size="9">
<optgroup label=" Автомати ">
<option value="1"> AK-47 </option>
<option value="2"> M4A4 </option>
<option value="3"> M4A1-S </option>
</optgroup>
<optgroup label=" Снайперські ">
<option value="4" selected="selected"> AWP </option>
<option value="5"> SSG 08 </option>
</optgroup>
<optgroup label=" Пістолети ">
<option value="6"> Desert Eagle </option>
<option value="7"> Glock-18 </option>
</optgroup>
<optgroup label=" Гранати ">
<option value="8"> димова </option>
<option value="9"> світлошумова </option>
</optgroup>
</select>
select is a list to choose from, size says how many rows are visible at once, and optgroup gathers options under a heading that cannot itself be chosen.
<!-- 13) повзунок --> <h2> Повзунок: скільки раундів до перемоги </h2> <input type="range" min="3" max="13" step="1">
<!-- 14) пошук --> <h2> Пошук </h2> <label for="site-search"> Пошук: </label> <input type="search" id="site-search" name="q" aria-label="Пошук по сайту"> <button> Знайти </button>
<!-- 15) тиждень --> <h2> Тиждень турніру </h2> <input type="week"> <!-- 16) дата і час --> <h2> Дата й час матчу </h2> <input type="datetime-local">
<!-- 17) колір --> <h2> Колір прицілу </h2> <form action="sent.html" method="GET"> <p align="left"> Виберіть колір прицілу </p> <input type="color" name="color1"> <input type="submit" value="Send"> </form>
These are all the same input tag with a different type: range, search, week, datetime-local, color. The browser supplies the slider, the calendar and the colour picker — a few years earlier each of those meant a library of JavaScript.
A phone goes further and shows a different keyboard for each type. It costs one word in the markup.