CS1116/CS5018

Web Development 2

Dr Derek Bridge

School of Computer Science & Information Technology

University College Cork

Server-side programs that expect user input

A web page that contains a form

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>Challenge</title>
    </head>
    <body>
        <p>
            Halt! Who goes there?
        </p>
        <form action="response.py" method="get">
            <input type="text" name="firstname" />
            <input type="text" name="surname" />
            <input type="submit" />
        </form>
    </body>
</html>

The form element

The input element and its type and name attributes

Text entry fields

Reset buttons

Submit buttons

How can we tell the user what to type?

The title attribute

The placeholder attribute

The label element

The for attribute

How can we group the controls in a form?

CSS for forms

Two working examples

<form action="https://www.google.com/search" method="get">
    <label for="search">Oogle: </label>
    <input type="text" name="q" id="search" />
    <input type="submit" />
</form>
<form action="https://www.imdb.com/find" method="get">
    <label for="search">MovieMe: </label>
    <input type="text" name="q" id="search" />
    <input type="submit" />
</form>