More JavaScript Examples Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Microsoft Expression Web-Illustrated Unit K: Working with Behaviors.
Advertisements

Power Point Basics Create New Slide Shows Make Existing Shows Interactive Created By: Olivia Krause 2007.
Months of the year December January November October February
Chapter 08: Adding Adding Interactivity Interactivity With With Behaviors Behaviors By Bill Bennett Associate Professor MSJC CIS MVC.
Web Time Entry. – Logging on to Self Service – Accessing Self Service Web Time Sheet – Biweekly and Monthly web time entry – Temporary and Student web.
The Web Warrior Guide to Web Design Technologies
Introduction to JavaScript Please see speaker notes for additional information!
2012 CALENDAR. JANUARY 2012 Sunday 日 Monday 月 Tuesday 火 Wednesday 水 Thursday 木 Friday 金 Saturday 土
JavaScript 101 Lesson 01: Writing Your First JavaScript.
1 HCI 201 JavaScript - Part 1. 2 Static web pages l Static pages: what we have worked with so far l HTML tags tell the browser what to do with the content.
January 2012 Monday Tuesday Wednesday Thursday Friday Sat/ Sun / /8 14/15 21/22 28/
USC’s Internet-based Time and Attendance Management System.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Computer Science 103 Chapter 4 Advanced JavaScript.
R25 Webviewer Training. Creating a User Account When you go to the R25 Facility Request Form,R25 Facility Request Form this is the screen that will appear.
JavaScript Switch Statement. Switch JavaScript Switch Statement If you have a lot of conditions, you can use a switch statement instead of an if…elseif…
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAY WEEK WEEK WEEK WEEK WEEK CALENDAR PROJECT.
JQuery CS 268. What is jQuery? From their web site:
BETTER MANAGING OUR TIME KRONOS TIMEKEEPER SCHEDULING TRAINING YMCA OF METROPOLITAN DALLAS August 30, 2015.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
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.
Using Object-Oriented JavaScript CST 200- JavaScript 4 –
What day is today? What`s the date?. Sunday Monday Tuesday Wednesday Thursday Friday Saturday What day is today?
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Chapter 3 : Processing on the Front End JavaScript Technically its name is ECMA-262, which refers to the international standard which defines it. The standard.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
JavaScript - Introduction Please use speaker notes for additional information!
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Banner Web for Finance Want to print reports for your department? Need reports for a specific period? Want to compare this fiscal year to the last fiscal.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
November 2007 LeaveTraq Training for Employees. Please Note The LeaveTraq computer screenshots used in this training will be from the LeaveTraq “Test”
Topic: An Introduction to JavaScript - from Beginning JavaScript by Wilton (WROX)
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Decision Making with Control Structures and Statements (non-audio version) © Dr. David.
ITCS373: Internet Technology Lecture 5: More HTML.
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
 HTML is hypertext markup language. It is a way for people to display their information with more complex pictures and text displays. Before HTML, messages.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
R25 WebViewer Training. Step One: Create a User Account When you go to this is the screen that will appear.
Variety of JavaScript Examples Please use speaker notes for additional information!
WORD JUMBLE. Months of the year Word in jumbled form e r r f b u y a Word in jumbled form e r r f b u y a february Click for the answer Next Question.
Click the button to begin. 12:25 What time does this clock show? 5:00 4:00.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
Introduction to ASP.NET Please use speaker notes for additional information!
JavaScript, Fourth Edition
Ceridian Time Solutions Hourly/Non-Exempt & (Non- Contracted) Per Diems Key Entry.
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
Ceridian Time Solutions Supervisor. IMPORTANT If you are not the manager of an employee but have been assigned the task of approving time for that employee,
Lesson 16. Practical Application 1 We can take advantage of JavaScript and the DOM, to set up a form so that the first text box of a form automatically.
Creating Web Documents: JavaScript Ftp / file management: review Introduction to JavaScript Sources Homework: start review for midterm, work on Project.
Project Two Adding Scrolling Messages! Page 2.4 to 2.18 Today’s Agenda Look at scrolling message coding. Create a web page with a text box. Create a web.
CISW CRC - Fishman 2014 / 2015 PRESENTATION 4b: CISW 400 (Online) – Client-side Scripting for the Internet Cosumnes River College Fishman – 2015.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
Tutorial 11 1 JavaScript Operators and Expressions.
Making Pages Dynamic Chapter 8 JavaScript for the WWW.
Working with the Window Object JavaScript considers the browser window an object, which it calls the window object.
The Calendar.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Functions Wouldn’t it be nice to be able to bring up a new animal and paragraph without having to reload the page each time? We can! We can place the.
EVERY WEEK Every week has seven days, See how many you can say.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Page Redirection When you click a URL to reach to a page X but internally you are directed to another page Y that simply happens because of page re- direction.
Integrating JavaScript and HTML
Introduction to JavaScript
Presentation transcript:

More JavaScript Examples Please use speaker notes for additional information!

Check Pay function whichType(payInfo) { if (window.document.payInfo.fullsal.checked == true) { window.document.payInfo.theType.value = "Salaried Employee"; } if (window.document.payInfo.fullhr.checked == true) { window.document.payInfo.theType.value = "Full Time Hourly Employee"; } if (window.document.payInfo.parttime.checked == true) { window.document.payInfo.theType.value = "Part Time Hourly Employee"; } Type of employee: Check the type of employee: Full time - salaried Full time- hourly Part time

Check Pay function whichType(fullsalRec,fullhrRec,parttimeRec,theTypeRec) { if (fullsalRec.checked == true) { theTypeRec.value = "Salaried Employee"; } if (fullhrRec.checked == true) { theTypeRec.value = "Full Time Hourly Employee"; } if (parttimeRec.checked == true) { theTypeRec.value = "Part Time Hourly Employee"; } Type of employee: Check the type of employee: Full time - salaried Full time- hourly Part time <INPUT TYPE = "button" VALUE = "Select type" onClick = "whichType(fullsal,fullhr,parttime,theType);">

Check Pay //Note that in the previous example I used check boxes and the way the if statements worked, //the last check box was the one that was used. In this example I am using radio buttons //which are more appropriate. //In this case there are three buttons named radiobutton - to access any one of them I //need to use an index (since there are three buttons with the same name they form an //array)

function whichType(radiobutton) { if (window.document.payInfo.radiobutton[0].checked == true) { window.document.payInfo.theType.value = "Salaried Employee"; } if (window.document.payInfo.radiobutton[1].checked == true) { window.document.payInfo.theType.value = "Full Time Hourly Employee"; } if (window.document.payInfo.radiobutton[2].checked == true) { window.document.payInfo.theType.value = "Part Time Hourly Employee"; } Type of employee: Check the type of employee: Full time - salaried Full time- hourly Part time

Check Pay function whichType(radiobuttonx) { if (radiobuttonx[0].checked == true) { window.document.payInfo.theType.value = "Salaried Employee"; } if (radiobuttonx[1].checked == true) { window.document.payInfo.theType.value = "Full Time Hourly Employee"; } if (radiobuttonx[2].checked == true) { window.document.payInfo.theType.value = "Part Time Hourly Employee"; } Type of employee: Check the type of employee: Full time - salaried Full time- hourly Part time

Playing with time tests! monthArray = new Array(12); monthArray[1]="January"; monthArray[2]="February"; monthArray[3]="March"; monthArray[4]="April"; monthArray[5]="May"; monthArray[6]="June"; monthArray[7]="July"; monthArray[8]="Auguest"; monthArray[9]="September"; monthArray[10]="October"; monthArray[11]="November"; monthArray[12]="December"; // This script sets up a 12 element array that contains the names of the months. Notice // that each element of the array is given the same name - in this case monthArray. The // number in [] after the name is an index. The first element in my array is going to // have an index of 1 and it is going to contain January. When I want to get the month // to display on my screen. I can simply use the month from the system as the index on // monthArray to get the correct written month. This is a far too brief explanation. Be // sure to look up arrays in a book or a tutorial. They can be tricky and you should spend // some time looking at examples and explanations! The CIS Department at BCC runs both day and evening classes. Day classes run from 8:00AM until 4:00PM DCE classes run from 4:00PM until 10:00PM Array Element[index] Content of Array monthArray[1] January monthArray[2] February monthArray[3] March monthArray[4] April monthArray[5] May monthArray[6] June monthArray[7] July monthArray[8] August monthArray[9] September monthArray[10] October monthArray[11] November monthArray[12] December

todaydate=new Date() tday = todaydate.getDate(); tmo = todaydate.getMonth() + 1; if (navigator.appName == "Netscape") { var tyr = todaydate.getYear() ; } else { var tyr = todaydate.getYear(); } var thr = todaydate.getHours(); document.write("After checking our clock for the date " + monthArray[tmo] + tday + ", " + tyr + " "); if (thr >=8 && thr <16) { document.write("Day school schedule is in effect!"); } else if (thr >=16 && thr < 22) { document.write("DCE schedule is in effect!"); } else { document.write("The campus is closed!"); } Here is where I should have concatenated with a space between month and day. Here I am taking the month from the date and adding 1 to it to put it in the range 1 to 12. Here I am using tmo as the index for monthArray to extract the correct month.

Playing with time tests! monthArray = new Array(12); monthArray[1]="January"; monthArray[2]="February"; monthArray[3]="March"; monthArray[4]="April"; monthArray[5]="May"; monthArray[6]="June"; monthArray[7]="July"; monthArray[8]="Auguest"; monthArray[9]="September"; monthArray[10]="October"; monthArray[11]="November"; monthArray[12]="December"; dayArray = new Array(7); dayArray[0] = "Sunday"; dayArray[1] = "Monday"; dayArray[2] = "Tuesday"; dayArray[3] = "Wednesday"; dayArray[4] = "Thursday"; dayArray[5] = "Friday"; dayArray[6] = "Satuday"; The CIS Department at BCC runs both day and evening classes. Day classes run from 8:00AM until 4:00PM DCE classes run from 4:00PM until 10:00PM New array for days of the week.

todaydate=new Date() tday = todaydate.getDate(); tdayword = todaydate.getDay(); tmo = todaydate.getMonth() + 1; if (navigator.appName == "Netscape") { var tyr = todaydate.getYear() ; } else { var tyr = todaydate.getYear(); } var thr = todaydate.getHours(); document.write("After checking our clock for the date " + dayArray[tdayword] + ", ” + monthArray[tmo] + tday + ", " + tyr + " "); if (thr >=8 && thr <16) { document.write("Day school schedule is in effect!"); } else if (thr >=16 && thr < 22) { document.write("DCE schedule is in effect!"); } else { document.write("The campus is closed!"); } Note this line has been wrapped on the slide - in the code it is one line. Extracting numbers that will be used as indexes or subscripts or pointers depending on your vocabulary choice. Using tdayword as the index to take the correct element from the dayArray.

Working with a banner // I am establishing an array of 6 elements called fstArray. The array will have an // index that can contain values 0, 1, 2, 3, 4, 5 (therefore the 6 elements). // The source for each element in the array is a different picture. // Note that the value of the array is that each element in the array has the same name // and by varying the subscript I can point to different elements. This makes it easy // to loop through the elements in the array by changing the index that points to the // different elements. fstArray[0] gets me the first image, fstArray[2] gets me the // second image etc. Be sure to read about arrays in a text or tutorial! fstArray = new Array(6); fstArray[0]=new Image; fstArray[0].src="house.jpg"; fstArray[1]=new Image; fstArray[1].src="street.jpg"; fstArray[2]=new Image; fstArray[2].src="path.jpg"; fstArray[3]=new Image; fstArray[3].src="snow.jpg"; fstArray[4]=new Image; fstArray[4].src="tree.jpg"; fstArray[5]=new Image; fstArray[5].src="houseusd.jpg"; index=0; I used a two step process to set up a new Image and then fill it with a specific image. I established an index and set it to 0.

function cycle() { document.rotate.src=fstArray[index].src; index=index+1; if (index==6) { index = 0; } setTimeout("cycle()",1000); } // setTimeout deals with the amount of time in milliseconds before the expression // refered to evaluates - in this example before cycle. This means that I have set // up an endless loop here because onLoad says to do cycle and within cycle I say to do // cycle - therfore the endless loop - a programming technique to use carefully! <IMG SRC="snow.jpg" NAME="rotate" WIDTH=50% HEIGHT=50%> Cycle is a function that calls itself so we have an endless loop.

Working with a banner fstArray = new Array(6); fstArray[0]=new Image; fstArray[0].src="house.jpg"; fstArray[1]=new Image; fstArray[1].src="street.jpg"; fstArray[2]=new Image; fstArray[2].src="path.jpg"; fstArray[3]=new Image; fstArray[3].src="snow.jpg"; fstArray[4]=new Image; fstArray[4].src="tree.jpg"; fstArray[5]=new Image; fstArray[5].src="houseusd.jpg"; index=0; function cycle() { document.rotate.src=fstArray[index].src; index=index+1; if (index==6) { index = 0; } Pictures of the Snow <IMG SRC="snow.jpg" NAME="rotate" WIDTH=50% HEIGHT=50%>

Changed location function newSite() { location="flickcol.html"; } CHANGE OF SITE! The function that takes you to a different location is a user-defined function. Most of the literature that I have read says that the best place to put a user-defined function is in the HEAD section so that it is defined and loaded prior to use. JavaScript functions can be called by using the function name as I did below when I set up the time out. In this case then, I have the time out method calling and thereby executing the new site user-defined function. var line1 = "This site has moved - please click on this URL if you do not automatically "; var line2 = "go to the new site in 10 seconds. Click here "; document.write(" "+line1+line2+" "); setTimeout("newSite()",10000); This function gives the location of the new site. The user can stop the automatic move by clicking on Click here which will send them to the same location shown in the function. setTimeout gives the time before executing the function called newSite which contains the new location.

With popup window.open("msgpopup.html","msgWin","WIDTH=400,HEIGHT=400"); COMPUTER INFORMATION SYSTEMS The Computer Information Systems Department has 5 degree options and 5 certificates. Degree Options Programming Career Networking Career Multimedia and Internet Career Microcomputers for Business Career Information Systems Transfer Comments: The syntax for the open() method is open("URL","name", options); where the URL is the name of the page you want to open in the new window, the name is the name of the new window and the options are things like the width and height of the new window. Note that window.open can also be written as open in most cases.

With popup open("msgpopup.html","msgWin","WIDTH=400,HEIGHT=250,SCROLLBARS") COMPUTER INFORMATION SYSTEMS The Computer Information Systems Department has 5 degree options and 5 certificates. Degree Options Programming Career Networking Career Multimedia and Internet Career Microcomputers for Business Career Information Systems Transfer

Menu Window <!-- hide from older browsers var menuWindow = window.open("athemenu.html","menuWindow","width=200,height=100,resizable"); menuWindow.moveTo(150,200); // end hide --> This page brings up a window with a series of menu choices. The window is resizable and moved to a specific location In this example I am assigning the results of opening the menu to the variable menuWindow which means that I can then refer to menuWindow as I did when I moved the window to a specific location.

The Menu <!-- hides var recentVersion = false; var whichVer = parseInt(navigator.appVersion); if ((navigator.appName == "Netscape") && (whichVer > 2)) { recentVersion = true; } else if ((navigator.appName == "Microsoft Internet Explorer") && (whichVer > 3)) { recentVersion = true; } // shows --> <A HREF="#" onClick="window.opener.location= ' if (recentVersion) {window.focus();}">Bristol <A HREF="#" onClick="window.opener.location= ' if (recentVersion) {window.focus();}">Grocer Home Page <A HREF="#" onClick="window.opener.location= ' if (recentVersion) {window.focus();}">Back to original Again, I am wrapping to fit on the slide. The A HREF lines are one line.