-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhtml-forms-lecture.html
More file actions
238 lines (190 loc) · 7.38 KB
/
html-forms-lecture.html
File metadata and controls
238 lines (190 loc) · 7.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!DOCTYPE html>
<html>
<head>
<title>Form Lecture</title>
</head>
<body>
<!--
Form Types
Syntax
Method attribute (the HTTP verb used to transmit the data)
Action attribute (where the form data is submitted)
Query Strings (key-value pairs appended to the URL when making a GET request)
Submitting forms
Input types
Labels
Attributes (name and value)
-->
<h1>HTML Forms</h1>
<!-- <hr>-->
<!-- <h2>Standard Form</h2>-->
<!-- <form method="POST" action="">-->
<!-- <label for="username">Username</label>-->
<!-- <input id="username" name="username" type="text">-->
<!-- <br>-->
<!-- <label for="password">Password</label>-->
<!-- <input id="password" name="password" type="password">-->
<!-- <br>-->
<!-- <input type="submit">-->
<!-- </form>-->
<!-- <h2>Method and Action Attributes</h2>-->
<!-- METHOD ATTRIBUTE -->
<!--
Primary HTTP Methods:
1) GET
2) POST
3) PUT
4) PATCH
5) DELETE
HTML only allows GET and POST methods because the specifications have not been finalized yet
GET -VS- POST
Less secure ---- "More" secure
Cachable and bookmarkable ---- Not cachable or bookmarkable
A request for information from a server ---- A request to submit information to a server
Use when searching or linking ---- Use for submitting data to be stored
Limited to 3000 characters ---- Can send large amounts of data
For additional information: "https://www.w3schools.com/tags/ref_httpmethods.asp"
-->
<!-- GET -->
<!--<h4>Using GET</h4>-->
<!--<form method="GET" action="">-->
<!--<input type="hidden" name="q" value="Codeup">-->
<!--<button type="submit">Submit</button>-->
<!--<!– <input type="submit"> –>-->
<!--</form>-->
<!-- POST -->
<!--<h4>Using POST</h4>-->
<!--<form method="POST" action="">-->
<!--<input type="hidden" name="q" value="Codeup">-->
<!--<button>Submit</button>-->
<!--</form>-->
<!-- NO METHOD SPECIFIED -->
<!--<h4>No method attribute</h4>-->
<!--<form action="">-->
<!--<input type="hidden" name="q" value="Codeup">-->
<!--<button>Submit</button>-->
<!--</form>-->
<!-- ACTION ATTRIBUTE -->
<!-- none -->
<!--<h4>Blank Action</h4>-->
<!--<form action="">-->
<!--<input type="hidden" name="q" value="Codeup">-->
<!--<button>Submit</button>-->
<!--</form>-->
<!-- GET Search -->
<!--<h4>GET Search</h4>-->
<!--<form method="GET" action="">-->
<!--<input type="hidden" name="q" value="Codeup">-->
<!--<button>GET DuckDuck</button>-->
<!--</form>-->
<!-- POST Search -->
<!--<h4>POST Search</h4>-->
<!--<form method="POST" action="">-->
<!--<input type="hidden" name="q" value="Codeup">-->
<!--<button>POST DuckDuck</button>-->
<!--</form>-->
<!-- POST Search to Google -->
<!--<h4>POST Search to Google</h4>-->
<!--<form method="POST" action="">-->
<!--<input type="hidden" name="q" value="Codeup">-->
<!--<button>POST Google</button>-->
<!--</form>-->
<!-- QUERY STRINGS -->
<!--
Three ways to make GET requests:
1) URL search
2) Clicking a link
3) Submitting a form
-->
<!-- <h3>Three Ways to Make a GET Request</h3>-->
<!-- <ol>-->
<!-- <li>Type address in address bar</li>-->
<!-- <li>-->
<!-- <a href="https://duckduckgo.com?q=codeup">Click a Link</a>-->
<!-- </li>-->
<!-- <li>-->
<!-- <form method="GET" action="">-->
<!-- <input type="hidden" name="q" value="Codeup">-->
<!-- <button>Submit a Form</button>-->
<!-- </form>-->
<!-- </li>-->
<!-- </ol>-->
<h2>Input Types and Attributes</h2>
<!-- INPUT TYPES AND ATTRIBUTES -->
<!-- Input types: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input -->
<form method="GET" action="https://hookb.in/7ZpjLjK9kPSa99D3R8kV">
<!--
Standard Input Elements
Text Input
Password Input
Hidden Input
Other Types: email, number, date, etc. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
Textarea
Checkboxes
Radio Buttons
Select/Dropdown Input
Required/Disabled Attributes
-->
<!-- Text -->
<!-- <h4>Text Input</h4>-->
<!-- <label for="movie">Favorite movie</label>-->
<!-- <input id="movie" type="text" name="movie" placeholder="Enter favorite movie">-->
<!-- Password -->
<!-- <h4>Password Input</h4>-->
<!-- <label for="password">Password</label>-->
<!-- <input id="password" type="password" name="password" placeholder="Enter password">-->
<!-- Hidden Inputs -->
<!-- <h4>Hidden Inputs</h4>-->
<!-- <input type="hidden" name="user_id" value="432">-->
<!-- Text area -->
<!-- <h4>Textarea Input</h4>-->
<!-- <label for="blog-post">Blog Post</label>-->
<!-- <textarea id="blog-post" name="blog-post" rows="7" cols="50" placeholder="Write blog post">Some text here</textarea>-->
<!-- Checkboxes -->
<!-- <h4>Checkbox Input</h4>-->
<!---->
<!-- <label for="newsletter-signup">Opt in to News Letter</label>-->
<!-- <input id="newsletter-signup" name="newsletter-signup" value="true" type="checkbox">-->
<!-- Multiple Checkboxes -->
<!-- <h4>Multiple Checkboxes</h4>-->
<!-- <fieldset>-->
<!-- <legend>Choose Toppings</legend>-->
<!-- <label for="pepperoni"><input id="pepperoni" name="topping" value="pepperoni" type="checkbox">Pepperoni</label>-->
<!-- <label><input name="topping" value="peppers" type="checkbox">Peppers</label>-->
<!-- <label><input name="topping" value="mushrooms" type="checkbox">Mushrooms</label>-->
<!-- <label><input name="topping" value="olives" type="checkbox">Olives</label>-->
<!-- </fieldset>-->
<!-- Radio Buttons -->
<!-- <h4>Radio Input</h4>-->
<!-- <fieldset>-->
<!-- <legend>Select Answer</legend>-->
<!-- <label>A <input type="radio" name="quiz-question-1" value="a"></label>-->
<!-- <br>-->
<!-- <label>B <input type="radio" name="quiz-question-1" value="b"></label>-->
<!-- <br>-->
<!-- <label>C <input type="radio" name="quiz-question-1" value="c"></label>-->
<!-- <br>-->
<!-- <label>D <input type="radio" name="quiz-question-1" value="d"></label>-->
<!-- <br>-->
<!-- </fieldset>-->
<!-- Selects (with or without multiple option) -->
<!-- <h4>Select Inputs</h4>-->
<!-- <label for="coffee-preference">Coffee Preference</label>-->
<!-- <select id="coffee-preference" name="coffee-preference">-->
<!-- <option value="light">Light Roast</option>-->
<!-- <option value="dark">Dark Roast</option>-->
<!-- <option value="espresso">Espresso Blend</option>-->
<!-- </select>-->
<!-- Required -->
<label for="firstName">First Name</label>
<input id="firstName" name="firstName" type="text" required>
<!-- Disabled -->
<label for="lastName">Last Name</label>
<input id="lastName" name="lastName" type="text" disabled>
<!-- Submit Button -->
<div>
<button>Submit</button>
</div>
</form>
</body>
</html>