diff --git a/class3.html b/class3.html index 2e1e345..dcd3169 100644 --- a/class3.html +++ b/class3.html @@ -366,6 +366,99 @@
HTML Forms allow users to enter information
+
+<form id ="about-me">
+ <input type = "text" id = "name" placeholder = "Enter a name"/>
+ <label>Do you like popcorn</label>
+ Yes <input type = "radio" name = "popcorn" val = "yes"/>
+ No <input type = "radio" name = "popcorn" val = "no"/>
+ <label>Favorite Dinosaur</label>
+ <select id = "dinosaur">
+ <option value = "t-rex">Tyrannosaurus Rex</option>
+ <option value = "tri">Triceratops</option>
+ <option value = "stego">Stegosaurus</option>
+ <option value = "other">Other</option>
+ </select>
+ <input type = "submit" value = "Go!" style = "padding: 7px; font-size:1em"/>
+</form>
+
+ HTML Forms allow users to enter information
+You can use JavaScript to get values from a form
+
+ $('#name').val();
+ $('select#dinosaur').val();
+ $('input:radio[name=popcorn]:checked').val();
+
+
+ $('#name').val('Mitch');
+ $('select#dinosaur').val('stego');
+ $('input:radio[name=popcorn]:checked').val('no');
+
+ jQuery has an event for form submission
+
+ $('#about-me').submit(function(event){
+ //code to execute after submission
+ return false;
+ });
+
+ "return false" to prevent the form trying to submit to a server.
+