Checkboxes, Select boxes, Radio buttons

Slides:



Advertisements
Similar presentations
Modifying existing content Adding/Removing content on a page using jQuery.
Advertisements

2-May-15 GUI Design. 2 HMI design There are entire college courses taught on HMI (Human-Machine Interface) design This is just a very brief presentation.
Adobe Forms THE FORM ELEMENT PANEL. Creating a form using the Adobe FormsCentral is a quick and easy way to distribute a variety of forms including surveys.
This is Google Drive. It stores all the documents you have made here.
Tutorial #9 – Creating Forms. Tutorial #8 Review – Tables Borders (table, gridlines), Border-collapse: collapse; empty-cells: show; and rowspan, colspan.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
1 VU. 2 CS101 Introduction to Computing Lecture 15 More on Interactive Forms (Web Development Lecture 5)
XP Dreamweaver 8.0 Tutorial 3 1 Adding Text and Formatting Text with CSS Styles.
Downloading and Installing Autodesk Revit 2016
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
HTML Forms.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
Downloading and Installing Autodesk Inventor Professional 2015 This is a 4 step process 1.Register with the Autodesk Student Community 2.Downloading the.
HTML Forms. Slide 2 Forms (Introduction) The purpose of input forms Organizing forms with a and Using different element types to get user input A brief.
CSC 240 (Blum)1 Introduction to Access CSC 240 (Blum)2 Click on the Access desktop icon or go to Start/Programs/Microsoft Office/Microsoft Office.
Forms Collecting Data CSS Class 5. Forms Create a form Add text box Add labels Add check boxes and radio buttons Build a drop-down list Group drop-down.
Modifying HTML attributes and CSS values. Learning Objectives By the end of this lecture, you should be able to: – Select based on a class (as opposed.
SYST Web Technologies SYST Web Technologies XHTML Forms.
Photoshop Image Slicing. Reasons to Image Slide To create links out of sliced images To optimise different areas. (flat areas of colour, such as logos,
CSC 240 (Blum)1 Introduction to Access CSC 240 (Blum)2 Click on the Access desktop icon or go to Start/All Programs/Microsoft Office/Microsoft Office.
Web Page Design Forms! Website Design. Objectives What forms can do The Attributes of the form tag Using Textboxes Textareas Checkboxes Radio buttons.
+ FORMS HTML forms are used to pass data to a server. begins and ends a form Forms are made up of input elements Every input element has a name and value.
Radio Buttons.  Quiz  Radio Buttons  Check boxes 2.
Review of HTML and CSS A (very) brief review of some key fundamentals to be aware of in IT-238.
1 HTML Forms
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 6: Creating XHTML Forms Kelly.
1 HTML forms (cont.)
Executive Summary - Human Factors Heuristic Evaluation 04/18/2014.
Check Boxes. 2 Check boxes  Image from:  HTML:  Each box gets it's own.
SurveyDIG 2.1 Tutorial. Tutorial Contents Introduction Introduction Item Groups Item Groups –Creating new Groups –Naming Convention –Searching/Editing.
Web Forms. Web Forms: A form allows our web visitors to submit information to us. Some examples uses for forms are to let the web user contact us, fill.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
How To Make Easysite Forms By Joshua Crawley Contact:
JavaScript: Conditionals contd.
Advanced HTML Tags:.
Microsoft Word 125 S. Clark St., 4th floor, Chicago, Illinois  Telephone  Fax
Web Forms.
SurveyDIG 2.1 Tutorial.
Intro to Dynamic HTML Intro to Forms
Web Forms.
Checkboxes, Select boxes, Radio buttons,
Objectives Design a form Create a form Create text fields
Collecting Information from the User
3.01 Apply Controls Associated With Visual Studio Form
(and available form fields)
Reviewing Documents Guided Lesson.
CS 0134 (term 2181) Jarrett Billingsley
Retrieving information from forms
3.01 Apply Controls Associated With Visual Studio Form
Section 10.1 YOU WILL LEARN TO… Define scripting
Adding Assignments and Learning Units to Your TSS Course
HTML Forms and User Input
Microsoft Word Reviewing Documents.
Introduction to Access 2003
Creating Forms on a Web Page
GUI Design 24-Feb-19.
BIT116: Scripting Radio Buttons.
© Hugh McCabe 2000 Web Authoring Lecture 8
Working with ‘checked’ items Checkboxes and Radio buttons
Web Forms.
Making your HTML Page Interactive
HTML Forms, Part 1 Image taken from "How to structure an HTML form" from Mozilla Developer Network.
JavaScript Part 2 Organizing JavaScript Code into Functions
Retrieving information from forms
The W3C More on images Entity codes Remote vs Local Computers
Presentation transcript:

Checkboxes, Select boxes, Radio buttons Intro to Forms, Part 2 Checkboxes, Select boxes, Radio buttons

Learning Objectives By the end of this lecture, you should be able to: Create a checkbox, select box, and radio button Explain the difference between the value attribute in a select option, and the value that goes between the option tags Explain the reason why a given group of radio buttons need to share the same name Discuss the concept of clarity as it applies to naming your form elements

Forms: Checkboxes When you want to give the user multiple selections, use a checkbox. If you want to limit the user to ONE selection, use a radio button. Clicking in the box places a checkmark inside. Just in case you didn't know!! Notice that unlike with buttons, the value attribute has NO bearing on the appearance of the box. The value of the attribute called value (yes, I realize that's a bit confusing) becomes important when it is passed to a script. More on this later.

Forms: Checkboxes cont. Who are your favorite composers? Beethoven: <input type="checkbox" id="chkBeethoven"> Bach: <input type="checkbox" id="chkBach"> Mozart: <input type="checkbox" id="chkMozart"> Brahms: <input type="checkbox" id="chkBrahms"> Stravinsky: <input type="checkbox" id="chkStrav"> Incidentally, note the use of the chk prefix. Please note that in the code above, I have left out certain structural elements such as <p> tags, <label> tags etc. I have done this for teaching purposes so that we can focus on the important / relevant aspects of the code. I will frequently do to so in this and other lectures.

Forms: Checkboxes cont. Do you agree to these terms? I agree: <input type="checkbox" id="chkAgree"> I disagree: <input type="checkbox" id="chkDisagree"> Pop-Quiz: Why is the checkbox a poor choice here? Answer: Because the user could check both boxes. A better choice would be a radio button.

The ‘checked’ attribute Do you agree to these terms? I agree: <input type="checkbox" id="chkAgree" checked="checked"> Note the checked attribute. Setting the value of this attribute to checked (yes, the value is the same as the attribute name) places a check in the box automatically when the page is first displayed. In theory, we could simply say checked as opposed to checked="checked". However, I think it's a good idea to remember that attributes are intended to be associated with a value. The checked attribute can be used with both checkboxes and radio buttons.

An aside: Positioning Note the fairly sloppy appearance of each line. Any good page designer will put some thought into giving their forms a neat appearance. We will discuss how to position items on a page using CSS towards the end of the course.

Forms: Select Box Similar to radio buttons, except that the options are hidden until the user clicks on the down arrow. Once the user has selected an option, the options are re-hidden. Useful for situations where you have many possible options to choose from. (E.g. “What year were you born?”) While you can easily hide 100+ years inside a select box, you could not do so with a radio button!

Forms: Select <label for="selMonthBorn"> Does not use the <input> tag. Instead, uses <select>. Yields a drop-down box from which the user can choose from a list of options. Every item visible in the dropdown is created using the <option> tag. <label for="selMonthBorn"> What month were you born? </label> <select id="selMonthBorn"> <option value="jan">January</option> <option value="feb">Febuary</option> <option value="mar">March</option> etc... </select> Important: Be sure that you do not confuse the value inside the option tags, with the prompt (which is what your viewers see) which is between the option tags.

Select Box: value vs option As mentioned previously, be sure not to confuse the value inside the option tags, with the prompt (which is what your viewers see) which is between the option tags. What year were you born? <select id="selYearBorn"> <option value="53">1953</option> <option value="54">1954</option> <option value="55">1955</option> </select>

Select Box: value vs option That being said, there is no reason why they can’t be the same. Here is an example: What year were you born? <select id="selYearBorn"> <option value="1953">1953</option> <option value="1954">1954</option> <option value="1955">1955</option> </select>

An IMPORTANT Aside! We have discussed the concept of ‘clarity’ on several occasions. In addition to how your code "looks" (e.g. whitespace), the concept of clarity also applies – and is perhaps even MORE important – when it comes to things like the identifiers (names) that you choose for your form elements. Pop-Quiz: Suppose you had a select box in which you asked the user what month they were born in. Which of the following identifiers do YOU think is the best choice for your select box? month selMB selMonth selMonthBorn Answer: I hope you can agree that selMonthBorn is a much easier name to understand when looking at someone's code.

Forms: Radio Buttons We use radio buttons when we want the user to be able to select only one out of all of the available options. Checking one radio button automatically deselects any other button. Important: To ensure that all of the radio buttons are grouped together (so that only one can be selected), we must add an additional attribute to our radio buttons called name. The key is that all of the buttons in a group must have the same name. Rate this movie from 1 to 5 stars: 1 stars : <input type="radio" id= "radOne" name="movieRating"> 2 stars: <input type="radio" id= "radTwo" name="movieRating"> 3 stars: <input type="radio" id= "radThree" name="movieRating"> 4 stars: <input type="radio" id= "radFour" name="movieRating"> 5 stars: <input type="radio" id= "radFive" name="movieRating"> By adding the attribute called name and by giving this attribute the same value for all of the buttons, those buttons will be grouped and the user will only be able to select ONE out of the whole group.

Forms: Radio Buttons cont. Again, use radio buttons when you want the user to be limited to only one possible choice: Who is your favorite composer? Beethoven: <input type="radio" id="radBeethoven" name="favComposer"> Bach: <input type="radio" id="radBach" name="favComposer"> Mozart: <input type="radio" id="radMozart" name="favComposer"> Brahms: <input type="radio" id="radBrahms" name="favComposer"> Stravinsky: <input type="radio" id="radStravinsky" name="favComposer"> And again, recall how for a group of radio buttons, we have included a name attribute. As discussed, this groups the buttons and thereby limits the user to selecting only one item out of that group.

<label> tag for radio Buttons Note that the <label> tag is for each individual prompt. It is NOT for the entire group. Who is your favorite composer?  This is NOT the label! <label for="radBeethoven"> Beethoven: </label> <input type="radio" id="radBeethoven" name="favComposer"> <label for="radBach"> Bach: <input type="radio" id="radBach" name="favComposer"> <label for="radMozart">Mozart: </label> <input type="radio" id="radMozart" name="favComposer"> <label for="radBrahms">Brahms: </label> <input type="radio" id="radBrahms" name="favComposer"> <label for="radStravinsky">Stravinsky: </label> <input type="radio" id="radStravinsky" name="favComposer">

Radio Button: Complete Example Here is the complete code. Note that this is one situation where the single line break tag, <br> is useful. A complete paragraph between each radio button would probably be too much. Who is your favorite composer?<br> <label for="radBeethoven">Beethoven: </label> <input type="radio" id= "radBeethoven" name="favComposer"><br> <label for="radBach">Bach: </label> <input type="radio" id="radBach" name="favComposer"><br> <label for="radMozart">Mozart: </label> <input type="radio" id="radMozart" name="favComposer"><br> <label for="radBrahms">Brahms: </label> <input type="radio" id="radBrahms" name="favComposer"><br> <label for="radStravinsky">Stravinsky: </label> <input type="radio" id="radStravinsky" name="favComposer"><br>

<input type="file" id="fileAttach"> Forms: File Shows a textbox and a Browse button that allows the user to select a file from their computer. E.g. Used to choose a file to attach to an e-mail message. We will not be using this control in this course, but feel free to try it out. <input type="file" id="fileAttach">

Forms: Keep ‘em neat Unfortunately, this apparently simple task requires some slightly challenging CSS We will discuss “layout and positioning” later in the course

Hack: One way to line things up There is a character entity called the “non-breaking space”:   This entity allows you to add multiple spaces and can therefore force content to be pushed over to the right. This technique is a bit of a cheat, but in the short term, it’s a way to at least try and exert some control over the layout of your pages. (Example on next slide) We will have a talk on how to use CSS for layout and positioning at the end of the course. Do not spend a lot of time using this entity to line things up. In the “real world” using the non-breaking space is considered a POOR solution for positioning items on a page.

Example using   First Name: TEXT BOX  5 spaces before the text box Middle Initial: TEXT BOX  2 spaces before the text box Last Name: TEXT BOX  6 spaces before the text box Code: First Name:     <input type="text.... Middle Initial:  <input type="text.... Last Name:      <input type="text... Again, please note that this is NOT an ideal solution. I’ve only discussed it here to help if a small amount of space somewhere is driving you nuts – it happens! The proper solution is to use CSS layout and positioning techniques. We will not cover CSS positioning until the end of the course, however, you are certainly free to read up on it in advance and apply it to your pages!

Example: form_with_select_radio.html Pop-Quiz: For the month born, we could have used either a select box or a radio button. Both would "work" just as well. Why do you think it was decided to use a select box? Answer: Having all 12 months as radio buttons would take up a lot of real-estate on the web page. It would add unnecessary clutter. As a more extreme example, imagine if we were asking about the birth year with over 100 options!