03Form Table-edited
03Form Table-edited
Table
Basic Table Tags
Page 2
Web Programming
Table
Basic Table Tags
Page 3
Web Programming
Table
Example :
<table width="37%"
border="1">
<tr>
<td
width="47%">Nama</td>
<td
width="53%">IC</td>
</tr>
<tr>
<td>Ahmad</td>
<td>1234</td>
</tr>
<tr>
<td>Rashid</td><td>5678</t
d>
</tr>
</table>
January 4, 2025 Page 4
Web Programming
Example :
Table + Hyperlinks
Example :
…………..
<tr>
<td><a href="ITC443.html">
» ITC443 </a>
</td>
</tr>
……………..
Table + List
<table width="27%" border="1">
Example : <tr>
<td width="6%">Bil</td>
<td width="94%">Tajuk</td>
</tr>
<tr>
<td>1.</td>
<td><ol>
<li>Nota 1</li>
<li>Nota 2</li>
</ol></td>
</tr>
<tr>
<td>2.</td>
<td><ol>
<li>Exercise 1</li>
<li>Exercise 2</li>
</ol></td>
</tr>
</table>
Exercise : Table
Table
rowspan and colspan Attributes
Page 9
Web Programming
Table
rowspan example
Page
Web Programming
Table
rowspan example
Page
Web Programming
Table
colspan example
Page
Web Programming
Table
colspan example
Page
Web Programming
Exercise : Table
Exercise : Table
Table
align and valign Attributes
Page
Web Programming
Table
align and valign Attributes
Page
Web Programming
Table
align and valign example
<body>
<table border="1">
<caption>Fruit Juice Drinks</caption>
<tr>
<th></th>
<th>Apple</th>
<th>Orange</th>
<th>Banana</th>
</tr>
<tr>
<th>Breakfast</th>
<td align="center">0</td>
<td>1</td>
<td valign="top" rowspan="3">Yes, we have no bananas</td>
</tr>
<tr>
<th>Lunch and <br />lunch some more<br/>and lunch still
until</th>
<td valign="bottom">1</td>
<td>0</td>
</tr>
<tr>
<th>Dinner</th>
<td>0</td>
<td>0</td>
</tr>
</table>
</body>
Page
Web Programming
Table
align and valign example
Page
Table Web Programming
Page
Table Web Programming
Page
Frame
With frames, you can display more than one HTML
document in the same browser window. Each HTML
document is called a frame, and each frame is
independent of the others.
Page
Frame
The Frameset Tag
The <frameset> tag defines how to divide the window into
frames
Each frameset defines a set of rows or columns
The values of the rows/columns indicate the amount of
screen area each row/column will occupy
<frameset cols="25%,75%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
</frameset>
Page
Frame
Example :
Form
• Form is a technique for capturing or collecting data from
users.
• Forms are used to collect data inputted by a user. They can be
used as an interface for a web application, for example, or to
send data across the web.
• Data that users enter on a web page normally is sent to a Web
server.
• At this stage you will need server side scripting (php
programming) to achieve this objective.
• Example :
Basic Form
• A <form> is an area that can contain form elements
• The syntax is: <form parameters> ...form elements... </form>
• Form elements include: buttons, checkboxes, text fields, radio
buttons, drop-down menus, etc
• A form usually contains a Submit button to send the information
in the form elements to the server
• The form’s parameters tell how to send the information to the
server
• Example :
<html>
<body>
<form parameters>
form elements ….
………..
</form>
</body>
</html>
Basic Form
• The syntax is: <form parameters>
• “method” attribute :- whether post or get value. (We will see
some examples to understand this)
• “action” attribute :- URL of filename. To state a file that is
going to be opened after clicking the submit button.
Normally, it is the file that receives value from the form.
<html>
<body>
</form>
</body>
</html>
Basic Form
• Example :
<HTML>
<TITLE>Form Exercise</TITLE>
<BODY>
<P> This is a form: </P>
<FORM method=“post” action=“”>
<p>Username : <input type="text" name=“nama">
</p>
<p>Password : <input type=“password"
name=“password"></p>
<p><input type="submit" name="Submit"
value="Submit"></p>
</FORM>
</BODY>
</HTML>
HTML Forms
Richer way to interact with server
Form elements –
The <input> tag
• There are three basic tags used to capture input in Forms: INPUT,
SELECT, and TEXTAREA
• Most, but not all, form elements use the input tag, with a type="..."
argument to tell which kind of element it is
• type can be text, checkbox, radio, password, hidden, submit, reset,
button
• Other common input tag arguments include:
• name: the name of the element
• id: a unique identifier for the element
• value: the “value” of the element; used in different ways for different values of
type
4. <input type="email">
5. <input type="number">
6. <input type="file">
7. <input type="tel">
8. <input type="url">
January 4, 2025 Page 32
Web Programming
Input tag
text field:
<input type="text" name="textfield" value="with an initial val
password field:
<input type="password" name="textfield3" value="secret" />
• Note that two of these use the input tag, but one uses textarea
33
Web Programming
Form Structure
Web Programming
Query Strings
At the end of the day, another string
Web Programming
<form> element
GET vs POST
Web Programming
GET vs POST
Advantages and Disadvantages
GET
Data can be clearly seen in the address bar.
Data remains in browser history and cache.
Data can be bookmarked
Limit on the number of characters in the form data
returned.
POST
Data can contain binary data.
Data is hidden from user.
Submitted data is not stored in cache, history, or
bookmarks.
Web Programming
</FORM>
</BODY>
</HTML>
<datalist> An HTML5 element form defines lists to be used with other form elements.
<input> Defines an input field. HTML5 defines over 20 different types of input.
textarea Creates a multiline text entry box. <textarea rows="3" ... />
password Creates a single line text entry box for a password <input type="password" ... />
search Creates a single-line text entry box suitable for a search string. This is an HTML5 element.
email Creates a single-line text entry box suitable for entering an email address. This is an HTML5 element.
tel Creates a single-line text entry box suitable for entering a telephone. This is an HTML5 element.
url Creates a single-line text entry box suitable for entering a URL. This is an HTML5 element.
Pattern attribute
datalist
Web Programming
Select Lists
Chose an option, any option.
Select Lists
Select List Examples
Web Programming
Radio Buttons
Radio Buttons
Web Programming
Checkboxes
Checkboxes
Web Programming
Button Controls
Type Description
<input type="submit"> Creates a button that submits the form data to the server.
<input type="reset"> Creates a button that clears any of the user’s already
entered form data.
<input type="image"> Creates a custom submit button that uses an image for its
display.
Buttons
• A submit button:
<input type="submit" name="Submit" value="Submit" />
• A reset button:
<input type="reset" name="Submit2" value="Reset" />
• A plain button:
<input type="button" name="Submit3" value="Push Me" />
55
Web Programming
Button Controls
Web Programming
Hidden fields
57
Web Programming
Color
Web Programming
Exercises
Web Programming
Exercises
Web Programming
Exercises
Web Programming
Exercises
Web Programming
<html><head>
<title>Chapter 4</title>
</head>
<body>
<form method=“post" action="">
<fieldset>
<legend>Details</legend>
<p>
Title:
<input type="text" name="title">
<p>
Country:
<select name="where">
<option>Choose a country</option>
<option>Canada</option>
<option>Finland</option>
<option>United States</option>
</select>
</p>
<input type="submit" name="submit">
</fieldset>
</form>
</body>
</html>
Web Programming
<html><head><title>Chapter 4</title></head>
<body>
<form method=“post" action="">
<fieldset>
<legend>Sample Text Fields</legend>
<p>
Title:<br>
<input type="text" name="title">
<p>
Password:<br>
<input type="password" name="pass" size="8">
<p>
Email:<br>
<input type="email" name="email" size="45">
<p>
Website:<br>
<input type="url" name="website" size="45"/>
<p>
Description: <br>
<textarea placeholder="enter a description" rows="5"
cols="45"></textarea>
<p>
<input type="submit" name="Submit">
</fieldset>
</form>
</body>
</html>
<html><head><title>Chapter 4</title> Gender of Traveller:<br> Web Programming
</head><body> <input type="radio"
<form method=“post" action=""> name="gender" value="1">Female
<fieldset> <br>
<legend>Sample Choice Controls</legend> <input type="radio"
<p> name="gender" value="2">Male
Countries:<br> <br>
<select name="country"> <p>
<option>Australia</option> How did you hear about the
<option>Canada</option> site:<br>
<option>France</option> <input type="checkbox"
<option>Sweden</option> name="hear" value="email">Email<br>
<option>Thailand</option> <input type="checkbox"
<option>United States</option> name="hear" value="friend">Friend<br>
</select> <p>
Continent:<br> <input type="checkbox"
<select size="4" name="continent"> name="hear" value="website">Website
<option value="NA">North <p>
America</option>
<option value="EU">Europe</option> <input type="submit"
<option value="AS">Asia</option> name="Submit">
<option value="SA">South </fieldset>
America</option>
</select> <p> </form></body></html>
City:<br>
<select name="city">
<optgroup label="North America">
<option>Calgary</option>
<option>Los Angeles</option>
</optgroup>
<optgroup label="Europe">
<option>London</option>
<option>Paris</option>
<option>Prague</option>
</optgroup>
</select> <p>