Ada beberapa atribut yang dimiliki oleh HTML untuk pembuatan form:
- Text boxes
- Check boxes
- Radio buttons
- Combo boxes
- List boxes
- Submit Button
- etc...
<form>
content
</form>
ada beberapa argumen yang berhubungan dengan perintah yang diberikan:
- action = "url"
mengarahkan ke mana data akan dikirim
- method = "get"
pengiriman data melalui url
- method = "post"
pengiriman data melalui sistem sehingga lebih aman
- target = "target"
menspesifikasikan lokasi url action dibuka pada browser
A Text field:
<input type="text" name="textfield" value="with an initial
value">
A
multi-line text field:
<textarea name="textarea" cols="20"
rows="2">Hello</textarea>
A
password field:
<input type="password" name="textfield3"
value="secret">
A checkbox:
<input type="checkbox" name="checkbox" value="checkbox"
checked>
Radio
buttons:
<input type="radio" name="radiobutton"
value="myValue1">
male<br>
<input type="radio" name="radiobutton" value="myValue2" checked>
female
A
menu or list:
<select name="select">
<option value="red">red</option>
<option value="green">green</option>
<option value="BLUE">blue</option>
</select>
<select name="select">
<option value="red">red</option>
<option value="green">green</option>
<option value="BLUE">blue</option>
</select>
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">
Berikut merupakan contoh pembuatan sebuah code untuk form pendaftaran:
<html><head>
<title>latihan</title>
</head>
<body>
<h2>Registration Form:</h2>
<table>
<form method="post">
<tr>
<td><label> Name : </label> </td>
<td><input type="text" name="name"> </td>
</tr>
<tr>
<td> <label> Email : </label> </td>
<td> <input type="text" name="email"> </td>
</tr>
<tr>
<td> <label> Password : </label> </td>
<td> <input type="password" name="pass"> </td>
</tr>
<tr>
<td> <label> Gender : </label> </td>
<td> <input type="radio" name="gender" value="m">Male
<input type="radio" name="gender" value="f">Female </td>
</tr>
<tr>
<td> <label> Country : </label> </td>
<td> <select name="select">
<option value="Indonesia">Indonesia</option>
<option value="Malaysia">Malaysia</option>
<option value="Singapore">Singapore</option>
</select> </td>
</tr>
<tr>
<td> <label> Address : </label> </td>
<td> <textarea name="address" rows="3"> </textarea> </td>
</tr>
<tr>
<td> <input type="submit" name="Submit" value="Submit"> </td>
</tr>
</form>
</table>
</body>
</html>
Hasilnya: