index.html
並新增檔案 post.html
//index.html
<li class="nav-item">
<a class="nav-link" href="post.html">發布待辦事項</a>
</li>
<input type="格式" name="名稱" value="預設值" placeholder="佔位字元">
text
(文字框)、hidden
(隱藏框)、password
(密碼框)、file
(上傳)name
最重要!一定要有!因為 name
送出後,會變成 PHP 的變數名稱。b4-form-group-text
快速產生一整組BootStrap4的文字輸入欄位<textarea name="名稱">預設值</textarea>
<select name="名稱" size=1>選項</select>
<option value="值">選項文字</option>
selected="selected"
[]
外,還要加上 multiple
屬性。<input type="radio" name="名稱" value="值 1">選項文字 1
<input>
,name 都要一樣才行! checked="checked"
<input type="checkbox" name="名稱[]" value="值 1">選項文字 1
<input>
[]
,如此會送出陣列。checked="checked"
<input type="submit" name="send" value="按鈕文字" class="btn btn-primary" />
可做出按鈕效果
<!DOCTYPE html>
<html lang="zh_TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>發布待辦事項</title>
</head>
<body>
事項:<input type="text" name="title" value="" placeholder="請輸入標題"> <br>
描述:<textarea name="directions" id="directions"></textarea> <br>
到期日:<input type="text" name="end" id="end"><br>
優先順序:<select name="priority" id="priority">
<option value="高">高</option>
<option value="中">中</option>
<option value="低">低</option>
</select>
<br>
是否完成:
<input type="radio" name="done" value="1" checked="checked">是
<input type="radio" name="done" value="0">否
<br>
指派對象:
<input type="checkbox" name="assign[]" value="爸爸" checked="checked">爸爸
<input type="checkbox" name="assign[]" value="媽媽">媽媽
<input type="checkbox" name="assign[]" value="哥哥">哥哥
<input type="checkbox" name="assign[]" value="妹妹">妹妹
<input type="checkbox" name="assign[]" value="我" checked="checked">我
</body>
</html>
post.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/fontawesome_css/all.css">
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<title>編輯待辦事項</title>
</head>
<body>
<div class="container">
<!-- b4-form-group-text -->
<div class="form-group">
<label for="title">待辦事項</label>
<input type="text" name="title" id="title" class="form-control" placeholder="待辦事項">
</div>
<!-- b4-form-texarea -->
<div class="form-group">
<label for="directions">描述</label>
<textarea id="directions" class="form-control" name="directions" rows="3"></textarea>
</div>
<div class="form-group">
<label for="title">到期日</label>
<input type="text" name="end" id="end" class="form-control" placeholder="到期日">
</div>
<!-- b4-form-select -->
<div class="form-group">
<label for="priority">優先順序</label>
<select class="form-control" name="priority" id="priority">
<option value="高">高</option>
<option value="中">中</option>
<option value="低">低</option>
</select>
</div>
<!-- b4-form-check-inline-->
<div class="form-group">
<label for="done">指派對象:</label>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="assign[]" value="爸爸"> 爸爸
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="assign[]" value="媽媽"> 媽媽
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="assign[]" value="哥哥"> 哥哥
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="assign[]" value="我"> 我
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="assign[]" value="妹妹"> 妹妹
</label>
</div>
</div>
<!-- b4-form-radio-inline-->
<div class="form-group">
<label for="done">是否完成:</label>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="done" id="done_1" value="1"> 是
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="done" id="done_0" value="0"> 否
</label>
</div>
<div class="text-center">
<input type="submit" name="send" value="儲存" class="btn btn-primary" />
</div>
</div>
</div>
</body>
</html>