2- Forms and JavaScript Course: Developing web- based applica<ons



Similar documents
Internet Technologies

<option> eggs </option> <option> cheese </option> </select> </p> </form>

c. Write a JavaScript statement to print out as an alert box the value of the third Radio button (whether or not selected) in the second form.

Further web design: HTML forms

HTML Tables. IT 3203 Introduction to Web Development

CS412 Interactive Lab Creating a Simple Web Form

Configuring iplanet 6.0 Web Server For SSL and non-ssl Redirect

JavaScript and Dreamweaver Examples

07 Forms. 1 About Forms. 2 The FORM Tag. 1.1 Form Handlers

PHP Form Handling. Prof. Jim Whitehead CMPS 183 Spring 2006 May 3, 2006

Viewing Form Results

Web Design and Development ACS Chapter 13. Using Forms 11/30/2015 1

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

HTML Forms. Pat Morin COMP 2405

HTML Forms and CONTROLS

Website Login Integration

Working with forms in PHP

FORM-ORIENTED DATA ENTRY

Upload Center Forms. Contents. Defining Forms 2. Form Options 5. Applying Forms 6. Processing The Data 6. Maxum Development Corp.

XHTML Forms. Form syntax. Selection widgets. Submission method. Submission action. Radio buttons

FORMS. Introduction. Form Basics

Intell-a-Keeper Reporting System Technical Programming Guide. Tracking your Bookings without going Nuts!

Dynamic Web-Enabled Data Collection

People Data and the Web Forms and CGI. HTML forms. A user interface to CGI applications

Inserting the Form Field In Dreamweaver 4, open a new or existing page. From the Insert menu choose Form.

Dreamweaver Tutorials Creating a Web Contact Form

By Glenn Fleishman. WebSpy. Form and function

Using Form Tools (admin)

Web Development 1 A4 Project Description Web Architecture

Introduction to XHTML. 2010, Robert K. Moniot 1

Now that we have discussed some PHP background

The Basics of Dynamic SAS/IntrNet Applications Roderick A. Rose, Jordan Institute for Families, School of Social Work, UNC-Chapel Hill

Designing and Implementing Forms 34

Sample HP OO Web Application

InPost UK Limited GeoWidget Integration Guide Version 1.1

TCP/IP Networking, Part 2: Web-Based Control

Fortigate SSL VPN 4 With PINsafe Installation Notes

Hello World RESTful web service tutorial

Implementing Specialized Data Capture Applications with InVision Development Tools (Part 2)

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Major Subject

Insight Student for Chromebooks - Auto Configuration

In order for the form to process and send correctly the follow objects must be in the form tag.

ABSTRACT INTRODUCTION %CODE MACRO DEFINITION

Understanding Cross Site Scripting

Forms, CGI Objectives. HTML forms. Form example. Form example...

Yandex.Widgets Quick start

Fortigate SSL VPN 3.x With PINsafe Installation Notes

CGI Programming. What is CGI?

Linklok URL TM V2.90

How to Make a Working Contact Form for your Website in Dreamweaver CS3

2. Follow the installation directions and install the server on ccc

Appendix for Tx5xx and P85x1 manuals

Tutorial 6 Creating a Web Form. HTML and CSS 6 TH EDITION

InternetVista Web scenario documentation

Chapter 5 Configuring the Remote Access Web Portal

Novell Identity Manager

Create A Google Site. Introduction to Sites. Create, format, and customize a site. Adapted from:

Step by step guides. Deploying your first web app to your FREE Azure Subscription with Visual Studio 2015

Website Planning Checklist

Embedding a Data View dynamic report into an existing web-page

BreezingForms Guide. 18 Forms: BreezingForms

Client-side Web Engineering From HTML to AJAX

<?php if (Login::isLogged(Login::$_login_front)) { Helper::redirect(Login::$_dashboard_front); }

7- PHP and MySQL queries

PHP Authentication Schemes

Chapter 2: Interactive Web Applications

PHP Tutorial From beginner to master

Real SQL Programming 1

Chapter 22 How to send and access other web sites

Dynamic Web Pages With The Embedded Web Server. The Digi-Geek s AJAX Workbook

JavaScript: Arrays Pearson Education, Inc. All rights reserved.

Lab 5 Introduction to Java Scripts

MERCHANT INTEGRATION GUIDE. Version 2.8

Setup Guide

JavaScript Basics & HTML DOM. Sang Shin Java Technology Architect Sun Microsystems, Inc. sang.shin@sun.com

ARCONICS CONTENT MANAGEMENT SYSTEM FOR UL

XHTML BASICS. Institute of Finance Management CIT Department Herman Mandari

How to Schedule Report Execution and Mailing

Cover Page. Dynamic Server Pages Guide 10g Release 3 ( ) March 2007

JISIS and Web Technologies

Dynamic Content. Dynamic Web Content: HTML Forms CGI Web Servers and HTTP

Installing and Sending with DocuSign for NetSuite v2.2

MASTERTAG DEVELOPER GUIDE

New Online Banking Guide for FIRST time Login

Script Handbook for Interactive Scientific Website Building

WebSphere Business Monitor V7.0 Script adapter lab

Web Programming with PHP 5. The right tool for the right job.

JWIG Yet Another Framework for Maintainable and Secure Web Applications

Contents. 2 Alfresco API Version 1.0

Perl/CGI. CS 299 Web Programming and Design

A table is a collection of related data entries and it consists of columns and rows.

collab.virginia.edu UVACOLLAB ECLPS: BUILDING COURSE PORTALS UVaCollab User Guide Series

Transcription:

2- Forms and JavaScript Course: Cris*na Puente, Rafael Palacios 2010-

1 Crea*ng forms

Forms An HTML form is a special section of a document which gathers the usual content plus codes, special elements called controls (checkboxes, radiobuttons, menus), etc. <FORM action="http://algunsitio.com/prog/usuarionuevo.php" method="post"> Nombre:<INPUT type="text" id="nombre"><br> Apellido:<INPUT type="text" id="apellido"><br> email:<input type="text" id="email"><br> <INPUT type="radio" name="sexo" value="varón"> Varón<BR> <INPUT type="radio" name="sexo" value="mujer"> Mujer<BR> <INPUT type="submit" value="enviar"><input type="reset"> </FORM> 3

Forms The form element is something like a container for all the controls inside a web page. Attributes: Action: refers to the program which will process the content of the form once sent. Name: name of the form to be referred to. It s optative, but it is highly recommended to include. Method: methods of sending data to the server. (Get by URL, Post by standard input stdio) Accept-charset: set of accepted characters. 4

Forms Data sending methods: get: with this method, the set of data is linked to the URL specified by the action attribute (using a question mark as a separator ("?") all this information is sent to the program in charge of processing it. post: with this method, the set of data is included and sent to the program in charge of processing it by the standard input/ output via. The post method is more secure than get. 5

Forms <html> <head> <title>php example</title> </head> <body> <H1>Ejemplo de procesado de formularios</h1> <FORM ACTION="procesa2.php" METHOD="GET"> Introduzca su nombre:<input TYPE="text" NAME="nombre"><BR> Introduzca sus apellidos:<input TYPE="text" NAME="apellidos"><BR> <INPUT TYPE="submit" VALUE="Enviar"> </FORM> </body> </html> 6

Forms Controls: text input The <input> tag defines the input fields in the form. Attributes: type=" type of field. maxlenght="" indicates the maximum number of characters. size="" maximum number of characters displayed on screen. value="" initial value on this field. name="" name to be referenced. http://www.w3schools.com/tags/tag_input.asp 7

Forms Controls: special text inputs These special types are useful for mobile devices 8

Forms Controls, bu>ons Defined by the <input> tag plus some attributes: type, followed by submit to send the data, or followed by reset to erase the data and leave the fields blank, or button to perform some action. value, to indicate the text inside a button (usually send or reset). name, to identify a button. <input type="button" value="cerrar esta ventana" onclick="window.close();"> http://www.w3schools.com/tags/tag_input.asp 9

Forms Controls, checkbox To select one or some options from several choices. (main difference with radiobutton). One option may be preselected (checked) when the page loads. <INPUT TYPE="label" value="correcto"> <INPUT TYPE="checkbox" name="c1" value= "1" onclick="if(this.checked == true){alert('verdadero!'); this.checked=false;}"> <INPUT TYPE="label" value="falso"> <INPUT TYPE="checkbox" name="c2" value= "0" onclick="if(this.checked == true){alert('falso!'); this.checked=false;}"> http://www.w3schools.com/tags/tag_input.asp 10

Forms Controls, special inputs There are some special inputs like: Password: this field won t display the characters while typing. It will display asterisks instead. Hidden: the value of this field can t be modifyed because the user can t see this field. It usually has a fixed value defined by the value attribute. Their attributes are the same as for text. <input type="password" name="clave" maxlength="5" size="6"> http://www.w3schools.com/tags/tag_input.asp 11

Forms Controls, radio Similar to checkbox, to select an option from some choices. Only one active field allowed. <input type="radio" name="g1" value="leche"> Leche<br> <input type="radio" name="g1" value="mant"> Mantequilla<br> <input type="radio" name="g1" value="queso" check="checked"> Queso http://www.w3schools.com/tags/tag_input.asp 12

Forms Controls, select lists The tags <select>...</select> hold the values to be selected from a list of choices. The attributes of the opening tag are: name="" identifies the selection tag. Size="" indicates the number of visible options. If it is 1, the selection will be a menu. If the value is greater than 1, the list will have a scroll bar. Multiple: indicates multiple selection (the user can select more than one option). http://www.w3schools.com/tags/tag_select.asp 13

Forms Controls, select lists The <option> tag indicates the different options. The selected attribute, indicates the default option. If it is not specified, it will be the first element on the list. <SELECT NAME="Colores" MULTIPLE> <OPTION VALUE="r">Rojo</OPTION> <OPTION VALUE="g">Verde</OPTION> <OPTION VALUE="b">Azul</OPTION> </SELECT> <BR><BR> <SELECT NAME="Colores" SIZE="1"> <OPTION VALUE="r">Rojo</OPTION> <OPTION VALUE="g">Verde</OPTION> <OPTION VALUE="b">Azul</OPTION> </SELECT> 14

2 Accesing form objects from JavaScript

Finding the object (using this) Names while crea*ng the object: <select name="var_name" OnChange="func+on_name(this)"> </select> Obtaining the object within a JavaScript func*on: func*on func*on_name(elem) { alert(elem.value); } 16

Finding the object (using geteelementbyid) Names while crea*ng the object: <select name="var_name" id="object_name" OnChange="func+on_name()"> </select> Finding any object within a JavaScript func*on: var elem; elem=document.getelementbyid("object_name"); 17

Finding the object (using document) Names while crea*ng the object: <form ac*on="save.php" name="form_name" > <select name="var_name" OnChange="func+on_name"> </select> </form> Accesing any object within a JavaScript func*on: var elem=document.form_name.var_name; 18

Content of different object types In general the following are always valid: elem.name name of the variable elem.value value typed in by the user Radio and checkbox: if (elem.checked) { alert(elem.value); //use the value only if checked } Select- one: selectvalue = elem.op*ons[elem.selectedindex].text; 19

3 Some prac*cal examples

Numeric Text field example JavaScript code: function format(elem) { var my_value; my_value=parsefloat(elem.value); elem.value=my_value.tofixed(2); } HTML code: Amount: <input onchange="format(this)" name="amount" value="1.00"> 21

Submit confirma<on (<form> event) JavaScript code function AskConfirmation () { var agree; agree=confirm("send data now?"); if (agree) { //code to check data goes here return true; } else { return false ; } } HTML code <FORM ACTION="http://www.iit.upcomillas.es/cgi-bin/test-cgi" NAME="myform" OnSubmit="return AskConfirmation()" > Name: <INPUT NAME="first_name" SIZE="15"><BR> <INPUT TYPE="SUBMIT" VALUE="Submit Form"> </FORM> 22

Submit confirma<on (buzon event) JavaScript code function AskConfirmation() { var agree; agree=confirm("send data now?"); if (agree) { //code to check data goes here return true; } else { return false ; } } HTML code <FORM ACTION="http://www.iit.upcomillas.es/cgi-bin/test-cgi" NAME="myform"> Name: <INPUT NAME="first_name" SIZE="15"><BR> <INPUT TYPE="SUBMIT" VALUE="Submit Form" OnClick="return AskConfirmation()" > </FORM> 23

Alberto Aguilera 25 28015 Madrid Tel +34 91 542 28 00 Fax + 34 91 542 31 76 Iwww.icai.upcomillas.es www.upcomillas.es