From 1ede7c05630ce6b6e43f573b37af74188bbca8ae Mon Sep 17 00:00:00 2001
From: Izzy Johnston HTML Forms allow users to enter information HTML Forms allow users to enter information You can use JavaScript to get values from a form jQuery has an event for form submissionLet's Develop It
HTML forms
+
+
+<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
+ Values from Forms
+
+
+ $('#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');
+
Values from Forms
+
+ "return false" to prevent the form trying to submit to a server.
+
+ $('#about-me').submit(function(event){
+ //code to execute after submission
+ return false;
+ });
+
Let's Develop It
+
+