Intro to Forms q HTML forms are used

  • Slides: 9
Download presentation

Intro to Forms q HTML forms are used to gather information from end-users. q

Intro to Forms q HTML forms are used to gather information from end-users. q A form can contain elements like radiobuttons, text fields, checkboxes, submit buttons and more. q **This HTML tutorial will not teach you how servers process input from HTML forms. If you want to learn more about processing form input, you can study/research ASP. **

Forms: Input Elements q Radio Buttons: let a user select ONLY ONE of a

Forms: Input Elements q Radio Buttons: let a user select ONLY ONE of a limited number of choices. q <input type="radio" /> defines a radio button. Code View: <form> <input type="radio" name=“grade" value=“ 9 th" /> Freshmen <input type="radio" name=“grade" value=“ 10 th" /> Sophomore <input type="radio" name=“grade" value="11 th" /> Junior </form> Browser View:

Forms: Input Elements q Text Fields: allows the user to type in text into

Forms: Input Elements q Text Fields: allows the user to type in text into the text field box. q <input type=“text" /> defines a one-line input field that a user can enter text into. Default width of a text field is 20 characters. Code View: <form> Car Make: <input type="text“ name="carmake" /> Car Model: <input type="text" name="carmodel" /> </form> Browser View:

Forms: Input Elements q Password Field: like the text field, it allows the user

Forms: Input Elements q Password Field: like the text field, it allows the user to type in text into the text field box but the characters are masked. q <input type=“password" /> defines a password field. Code View: <form> Password: <input type="password" name="password" /> </form> Browser View: with user input

Forms: Input Elements q Checkboxes: let a user select ONE or MORE options of

Forms: Input Elements q Checkboxes: let a user select ONE or MORE options of a limited number of choices. q<input type=“checkbox" /> defines a checkbox. Code View: <form> <input type="checkbox" name="language" value="spanish" /> I speak Spanish <input type="checkbox" name="language" value="french" /> I speak French </form> Browser View:

Forms: Input Elements q Drop-Down List: allows a user to select one option from

Forms: Input Elements q Drop-Down List: allows a user to select one option from a simple drop-down menu. Code View: Browser View: default view College Majors <form action=“”> <select name=“collegemajors"> <option value=“eng">English Major</option> <option value=“math">Math Major</option> <option value=“SS">Social Studies Major</option> <option value=“history“>History Major</option> </select> </form> with drop-down menu engaged

Forms: Input Elements q Submit Button: used to send form data to a server.

Forms: Input Elements q Submit Button: used to send form data to a server. The data is sent to the page referenced in the form's “action” attribute. The file defined in the action attribute processes the received input. q <input type=“submit" /> defines a submit button. Code View: <form name="input" action="html_form_action. asp" method="get"> User Login: <input type="text" name="user" /> <input type="submit" value="Submit" /> </form> Browser View:

Forms: Review HTML forms are used to gather information from endusers in the following

Forms: Review HTML forms are used to gather information from endusers in the following ways: Radio Buttons Password Field Drop-down List Text Field Submit Button Checkbox