web111a_chapt08.ppt html: section 8 javascript cgi programs (server side programs) common gateway...

14
web111a_chapt0 8.ppt HTML: Section 8 JavaScri pt CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across Internet Only programmer can alter the program Administrators can place limitations on user Potential overload of system Too many users at one time accessing programs Numerous languages Java Perl ASP PHP/FI C Can be complicated 8.0 2

Upload: emery-morrison

Post on 17-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

HTML: Section 8JavaScript

CGI Programs (Server Side programs)

Common Gateway Interface

• Run on server

• Communicate with user across Internet

• Only programmer can alter the program

• Administrators can place limitations on user

• Potential overload of system

• Too many users at one time accessing programs

• Numerous languages

• Java

• Perl

• ASP

• PHP/FI

• C

• Can be complicated

8.02

Page 2: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

CGI Programs (Server Side Programs)

Common Uses

• Ordering Systems (shopping carts)

• Credit Card Processing

• Search Engines

• Password Protection

• Web site development by user on-line

Client Side Programs

• Are executed by the browser

• Less complicated to write and maintain

• Can be tested locally – does not have to be on the internet

• Usually more responsive to the user

• Can do a lot of checking functions

• Is an interpretative language

• Most common languages

JavaScriptVBScriptPHP/FIASP

Page 3: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

CGI Programs (Server Side Programs)

Common Uses

• Ordering Systems (shopping carts)

• Credit Card Processing

• Search Engines

• Password Protection

• Web site development by user on-line

Client Side Programs

• Are executed by the browser

• Less complicated to write and maintain

• Can be tested locally – does not have to be on the internet

• Usually more responsive to the user

• Can do a lot of checking functions

• Is an interpretative language

• Most common languages

JavaScriptVBScriptPHP/FIASP

Page 4: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

Active Server Pages (ASP) code

http://www.ffpc.org/ File Name: main.asp

Note: HTML code embedded with the ASP code

<h4>It is <% =weekdayname(weekday(date)) %>, <% = date %> at <% = time %> in Fenton, Michigan.

</h4>

<% If Time >= #12:00:00 AM# and Time < #12:00:00 PM# then %>

<h2>Good Morning and welcome to The ...</h2>

<% elseif time >= #12:00:00 pm# and time < #6:00:00 pm# then %>

<h2>Good Afternoon and welcome to The ...</h2><p>

<% else %>

<h2>Good Evening and welcome to The ...</h2>

<% end if %>

Page 5: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

JavaScript

• Simple to use

• Client side program

Script Tag

Identifies script type to browser

<script src=“url” language=“JavaScript”>

JavaScript code

</script>

url = name of external program

Language = type of script to be executed

Page 6: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

Page 8.07: Hiding the script from non JavaScript browsers

<script language=“JavaScript”>

<!– Hide from non-JavaScript browsers

JavaScript program

// Stop hiding from older browsers -->

</script>

JavaScript: ignored by non-JavaScript browsers

HTML: comment tag – a non-JavaScript browser will ignore all the statements between the tags

//: JavaScript comment tag:

A non-JavaScript browser will ignore

A JavaScript browser would error as the verbiage is not JavaScript commands

Note: no src attribute means the script is built into the HTML document, not coming from an external file

Page 7: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

LAB: Figure 8-6, Page 8.08

Files are located at F:\Assign\Fulcher\web111a\tutorial.08

-------------------------------

JavaScript

document.write(“text to the screen – no line return”);

document.writeln(“text to the screen with a line return”);

May include HTML in JavaScript

LAB: Figure 8-7, Page 8.10

Writing a document to the screen

8.08

Page 8: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

Working with VariablesVariable: a named element in a program that stores

information

Store/gather information in one part of program to be used in another part

Assignment format: (Page 8.11)

variabl-ename = data-into-variable;

Example: (Page 8.11 – 8.12)

Year = 2003;

document.write(Year);

document.write(“The year is “ + Year);

8.11

Page 9: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

Variable TypesNumeric: numbers

One decimal position allowed

Dash (-) allowed to show negative

Can do arithmetic with this type

String: group of characters

Enclosed in quotes (“)

Letters of the alphabet

Numbers (cannot do arithmetic)

Boolean: logical one (yes) or zero (no) only

Null: has no value assigned

Declaring (creating) Variables

Var name-of-variable = value-of-variable;

Var Month; variable is nullVar Month = “December”; creates and assignsMonth = “December”; assigns a value

LAB: Figure 8-8, Page 8.14

8.12

8.12

Page 10: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

Date/Time ValuesFormat

Variable = DateObject.JavaMethod();

Get current date information

Variable = new Date();

Example:

Today = new Date();

Now, each of the Date Methods can access the date information

Figures 8-9, 8-10, Page 8.17

LAB: Figure 8-11, Page 8.18

8.16

8.16

Page 11: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

Expressions and OperatorsUse

Variables

Values

Operators

Perform actions within an expression

+ Increment (add)

+ Join two elements

+ to Increment

Var ThisMonth = today.getMonth()+1;

+ to Join elements

document.write(“Only “ + DaysLeft + “ days until Christmas”);

Arithmetic Operators

Figure 8-13, Page 8.20

8.19

8.19

8.20

Page 12: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

Expressions and OperatorsAssignment Operators

Assign one element (or result) to another element

=

Most common

element1 = element2;

+=

Uncommon

Used to concatenate string data

Assignment Operators

Figure 8-14, Page 8.22

8.21

8.21

8.21

Page 13: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

Math object and Math MethodsObjects: libraries of functions

Method: a specific function in an object

Math object

A set/group of math functions built into the browser program

Math method

Specific program (function) inside the Math object to handle a specific operation

Figure 8-15, Page 8.22

8.22

Page 14: Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across

web111a_chapt08.ppt

JavaScript FunctionsSeries of commands that perform an action (program)

function function_name(parameters) {

javascript commands; }

XmasDays Function Page 8.25

LAB: Figure 8-17 and 8-18, Page 8.27

8.23