Intro to Dynamic HTML Intro to Forms

Slides:



Advertisements
Similar presentations
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
Advertisements

Forms cs105. More Interactive web-pages So far what we have seen was to present the information. (Ex: tables. Lists,….). But it is not enough. We want.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Forms Review. 2 Using Forms tag  Contains the form elements on a web page  Container tag tag  Configures a variety of form elements including text.
Python and Web Programming
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
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.
XP Tutorial 6New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
 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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
1 Review of Form Elements. 2 The tag Used in between tags.  Form elements(text control, buttons, etc.. ) goes here. OR  Form elements(text control,
HTML Forms a form is a container for input elements on a web page input elements contain data that is sent to the web server for processing.
Web Forms. Survey or poll Contact us Sign up for an newsletter Register for an event Submit comments or feedback about our site Log in to a members-only.
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.
SYST Web Technologies SYST Web Technologies XHTML Forms.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 9 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
Week 10: HTML Forms HNDIT11062 – Web Development.
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.
XP Tutorial 6New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Intro to Dynamic HTML Forms - Part 1
Tutorial 6 Working with Web Forms
Section 10.1 Define scripting
Advanced HTML Tags:.
Web Forms.
Client-Side Internet and Web Programming
Web Forms.
Checkboxes, Select boxes, Radio buttons,
How to Write Web Forms By Mimi Opkins.
Objectives Design a form Create a form Create text fields
Forms Web Design Ms. Olifer.
HTML Forms Pat Morin COMP 2405.
FORMS IN HTML.
(and available form fields)
ITE 115 Creating Web Page Forms
HTML Forms CSC 102 Lecture.
Section 10.1 YOU WILL LEARN TO… Define scripting
HTML/XHTML Forms 18-Sep-18.
Designing Forms Lesson 10.
1.5 FORMS.
HTML: Basic Tags & Form Tags
Creating Form Elements
Web Development & Design Foundations with H T M L 5
FORM OBJECT When creating an interactive web site for the Internet it is necessary to capture user input and process this input. Based on the result of.
CNIT 131 HTML5 - Forms.
Web Development & Design Foundations with H T M L 5
Creating Forms on a Web Page
HTML Forms 18-Apr-19.
© Hugh McCabe 2000 Web Authoring Lecture 8
Lesson 6: Web Forms.
Web Forms.
Making your HTML Page Interactive
Unit 5 Create Forms.
HTML: Basic Tags & Form Tags
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
Checkboxes, Select boxes, Radio buttons
Presentation transcript:

Intro to Dynamic HTML Intro to Forms Mendelsohn – IT-130

Dynamic Web Pges “Dynamic” implies a page that can change in behavior or appearance after it has already been downloaded to the client and displayed. Contrast with static web pages, which are those that do not change in any way once the page has loaded.

Examples of dynamic web pages Roll-over buttons (buttons that change appearance when the user hovers over the button) Forms Animations (e.g. Flash) Client-side scripting (e.g. JavaScript, VBScript) Server-Side Scripting (e.g. Active Server Pages, Java Server Pages) Java applets (no longer very common)

Example: The BMR Calculator A form Allows the user to enter some information about themselves and estimates the their basal metabolic rate (the number of calories their body consumes at rest in a day). Dynamic HTML being used: A form to enter data A client-side JavaScript that parses the form and uses the data to come up with a calculated value View it here FYI: Calculating BMR is a debated topic in medical/nutrition circles. Be careful of which formula you use.

Another example – CDM Tutor Search DHTML Techniques in use: Form Server-side scripting (Active Server Pages) http://facweb.cs.depaul.edu/tutors/tutor_search.asp

Think of these principles as you surf. Easy tiger…. Dynamic pages such as those involving animations can be lots of fun to create, but don’t overdo it! Long flash intros, hyper-animated gifs, distracting colors/backgrounds, etc can prolong the time to display your page—and can be very distracting. http://www.tallyhouniforms.com/ http://www.bvs.com/bank/bank-training.asp http://www.thecreationmuseum.org Think of these principles as you surf.

Ask yourself: Does this technique/design increase the usability of my site? Does this technique/design help to convey information?

New Topic: FORMS Our first venture into creating interactive/dynamic web pages. Web page takes input from the user and processes it in some way: Calculator (e.g. BMR, Mortgage, etc) Stores information in a database (registering a purchased product, signing up for a mailing list) Submits information (e-mail customer support)

Overview of Forms Forms are made up of a group of input elements usually referred to as ‘controls’ or ‘elements’. Form controls such as buttons, text-boxes, drop-down boxes, check-boxes, etc are very easy to place on a page using the HTML techniques we have used so far. Don’t forget about making your layout organized and easy on the eye – tables are usually used to organize forms on a web page. A little later in this course we will examine techniques to position elements on a web page. Doing something with the information from a form requires writing instructions in the form of a scripting or a programming language (JavaScript, ASP scripting, etc) For now we’ll focus on learning the elements to create and layout a form on your web page. Once we begin JavaScript you will learn how to make your web pages respond to input from a form.

Basic Form - incomplete: <form> <input type="text" /> <input type="reset" /> <!-- other elements here…--> </form> The ‘form’ tag groups the all of the elements of a form together.

Form outline - correct… <form name="userInformation"> <input type="text" name="txtFirstName" /> <input type="reset" name="btnReset" /> </form> Note how each element has a ‘name’ attribute The ‘name’ attribute in the form tag is important when you want to pass form information to a script (which is almost always the case). It is also important if you have more than one form on a page. For this reason, we need a way to refer to the specific form as well as to each individual element of the form. Also note the naming conventions: Button names begin with ‘btn’ Text names begin with ‘txt’ Names separated by capital letters More on naming conventions for form elements later….

Forms: Text Boxes <input type="text" name="txtFirstName" /> Optional attributes include maxlength: sets the maximum value of characters It’s a good idea to include this attribute as the default value for this attribute is unlimited!. size: sets the length of the box Note: The prompt (“Name:”) is not printed by the form. You must code for it yourself.

Forms: Text Areas Similar to text boxes, but allows the user to type in lines of information. Instead of <input> tag, uses <textarea> tag. Optional attributes include cols and rows to specify the initial size of the box. (Not always precise). <textarea name="txtarComments" cols="25" rows="5"> </textarea> Note: You need a separate closing tag. You can NOT use the /> shortcut for the textarea tag.

Naming conventions In programming it is a very good idea to come up with a consistent style of naming things. We’ve already discussed naming conventions for FILE names. Now we’ll add a different naming convention for FORM element names. Sometimes a project manager will dictate the conventions. Other times it is up to you to decide on one. However, it is an excellent idea to have one as it will help clarify your coding. In this course, you MUST follow naming conventions once they are introduced. In the “real” world, it looks sloppy/careless/unprofessional when programmers fail to follow conventions. Many will thank you: Project collaberators Later debuggers You! (down the road)

IT-130 Naming convention for form elements For this course you are required to use the following convention when naming form elements: Buttons: btnName Text boxes: txtName Text areas: txtarName Checkboxes: chkName Radio buttons: radName Select menu: selName Hidden elements: hidName Others not specified here: you may decide… Nb: These conventions are my own (although others may use something similar).

Forms: Buttons You’ll nearly always want to include the ‘value’ attribute. This value is displayed inside the button. <input type="button" value="Obama" name="btnObama" /> <input type="button" value="McCain" name="btnMccain" /> Later you will learn to add another component to this tag connecting the button to a script.

Forms: Buttons - Submit Because submit is so common in forms, it has its own ‘shortcut’ button. The value attribute of the submit button displays text on the button If you don’t enter this attribute, the web page defaults to the text: ‘Submit Query’. Eg: <input type="submit" name =" btnSubmit" /> <input type="submit" name ="btnSubmit" value="Submit Me! "/>

Getting your button to do something Of course, the purpose of forms is to take the information entered by the user and do something with it. Reading (“parsing”) the form and then “doing” something with that information is usually the job of a script. We will use the ‘onclick’ attribute to connect our button to a script. <input type= " button" value=“Submit Form” name= " btnSubmit " onclick= " runSomeScript( ) " > More on this later…

<input type= "reset" /> Forms: Buttons - Reset Not used very much any more as users sometimes click this button inadvertently and end up erasing everything they have typed. For this reason, many web designers do not include this button. We won’t use it in this course. <input type= "reset" />

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. Notice that unlike with buttons, the value attribute has NO bearing on the appearance of the box. The value of ‘value’ becomes important when it is passed to a script. More on this later.

Forms: Checkboxes contd Who are your favorite composers? <br /> Beethoven: <input type="checkbox“ name=“chkBeethoven“ /> <br /> Bach: <input type="checkbox“ name=“chkBach“ " /> <br /> Mozart: <input type="checkbox" name=“chkMozart" /> <br /> Brahms: <input type="checkbox" name=“chkBrahms" /> <br /> Stravinsky: <input type="checkbox" name=“chkStrav" /> <br />

Forms: Checkboxes contd Do you agree to these terms? <br /> I agree: <input type="checkbox" name="chkAgree" checked="checked" /> <br /> I disagree: <input type="checkbox" name="chkDisagree“ /> <br /> Note the ‘checked’ attribute. This places a check in the box automatically when the page is displayed.

Forms: Checkboxes contd Do you agree to these terms? <br /> I agree: <input type="checkbox" name="chkAgree" /> <br /> I disagree: <input type="checkbox" name="chkDisagree“ /> <br /> Pop quiz: Why is the checkbox a poor choice here? Answer: Because the user could check both buttons.

An aside: 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 do this at a later time. If you want a quick and dirty (though not entirely legitimate) way, use the   entity.

Forms: Keep ‘em neat This requires use of some slightly challenging CSS We will discuss this later in the course Careful thought has been given to keeping the layout neat and uncluttered.

Forms: Select Box Similar to radio box, except that the options are hidden until the user clicks. Once the user has chosen, 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! (discussed next)

Forms: Select Does not use the ‘input’ tag, uses ‘select’. Yields a drop-down box from which the user can choose from a list of options. Each item in the menu is created using the <option> tag. 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. What month were you born? <br /> <select name="selMonthBorn"> <option value="jan">January</option> <option value="feb">Febuary</option> <option value="mar">March</option> </select>

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. However, there is no reason why they can’t be the same. Sometimes – though not all that often – this is an option: What year were you born? <br /> <select name="selYearBorn"> <option value="1953">1953</option> <option value="1954">1954</option> <option value="1955">1955</option> </select>

Forms: Radio Buttons Similar to checkboxes except the user may only select one option out of the group. Checking one selection automatically deselects any other. ** All buttons in a given group must have the same name. As with checkboxes, you can include the ‘checked’ attribute to give a default selection. Do you agree to these terms? <br /> I agree: <input type="radio" name="radAgree“ /><br /> I don't agree: <input type="radio" name="radAgree“ /> Note that the ‘name’ attribute has the same value for both.

Forms: Radio Buttons contd Again, use radio buttons when you want the user to be limited to only one possible choice: Who IS your favorite composer? <br /> Beethoven: <input type="radio" name="radFavComposer" /> <br /> Bach: <input type="radio" name="radFavComposer" /> <br /> Mozart: <input type="radio" name="radFavComposer" /> <br /> Brahms: <input type="radio" name="radFavComposer" /> <br /> Stravinsky: <input type="radio" name="radFavComposer" /> <br /> Again, note how the ‘name’ attribute has the same value for all options.

<input type="file" name="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. <input type="file" name="fileAttach" />

Forms: Hidden Used as a convenient way to pass information (relating to the form) to a script that the user has no need to see. <input type="hidden" name="hidCookieValue" value="cookie_info" />