c122oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/cis122/...of beige. onfocus can...

62
c122Oct2714.notebook 1 October 27, 2014 I have two images and I am bringing each of them up using mouse activity. Note that the information about onmouseover and onmouseout is within the <img> tag.

Upload: duongxuyen

Post on 16-Apr-2018

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

1

October 27, 2014

I have two images and I am bringing each of them up using mouse activity.Note that the information about onmouseover and onmouseout is withinthe <img> tag.

Page 2: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

2

October 27, 2014

Another approach is using the <a href to handle the onmouseover and onmouseout.  Note that I still have the same name for the image.

Page 3: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

3

October 27, 2014

Comparing to a third option

Page 4: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

4

October 27, 2014

Going back and looking at HTML5 forms, remember that we had the submit and reset which were bottons.

Now we have an onclick event which means that we can set upa button to click on and then code what we want to happen usingthe onclick event.

Page 5: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

5

October 27, 2014

Page 6: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

6

October 27, 2014

In this example I have an alert and multiple changes of background color.Note that on the one where there is both a onmouseover and onmouseout that both events are within the <a> tag and there is just one line saying CHANGE BACKGROUND! that these two events are tied to.

Page 7: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

7

October 27, 2014

A different approach to the same code. This time I have a paragraph to click on.

Page 8: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

8

October 27, 2014

Notice that with this approach I can still put my mouse over and out from these paragraphs but there is not the usual indication thatthese will cause an event to happen.

Page 9: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

9

October 27, 2014

Page 10: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

10

October 27, 2014

Page 11: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

11

October 27, 2014

Page 12: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

12

October 27, 2014

I went back and changed the course name so nowI am seeing "The data has been changed" again.

Page 13: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

13

October 27, 2014

Page 14: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

14

October 27, 2014

Page 15: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

15

October 27, 2014

Page 16: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

16

October 27, 2014

Again, just using the <p onclick does not make it clearthat this line should be clicked on (unless you read it and even then it somehow feels funny).

Page 17: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

17

October 27, 2014

Page 18: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

18

October 27, 2014

onFocus or onfocus when associated with body appears to act the same as onload.  Here when the page starts it has the focus and the background of beige.  onfocus can also be used to focus on individual areas of the form like a textbox.

Page 19: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

19

October 27, 2014

Page 20: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

20

October 27, 2014

Page 21: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

21

October 27, 2014

Starting Functions

Page 22: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

22

October 27, 2014

Page 23: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

23

October 27, 2014

Call the function basicHelloWorld().Within that function the alert is displayed.I decided to put the script that holds the functionin the head section.  I could also put it in thebody (frequently they are placed at the bottom).

Page 24: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

24

October 27, 2014

Page 25: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

25

October 27, 2014

I am sending the literal Ann to the function.  It is received as passedName.

Page 26: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

26

October 27, 2014

Page 27: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

27

October 27, 2014

Page 28: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

28

October 27, 2014

Page 29: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

29

October 27, 2014

Page 30: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

30

October 27, 2014

firstName received in firstReceived and lastNamereceived in lastReceived.  Note that in these examplesI am putting out the response in the function.

Page 31: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

31

October 27, 2014

I have been coding with prompts and alerts because they are quick and easy, but it is really better not to rely on popups.  It is far better to take in the information from fields on the form.

Page 32: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

32

October 27, 2014

Still putting information out with an alert.  We willchange that in a moment.

Page 33: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

33

October 27, 2014

Information comes in from the form. I use the onclickto call the function and I send the information fromthe textboxes on the form.

Notice that when I use the data I have to specify that I wantthe value of the field.  Value is one of the properties and theproperty I need to work with when I am doing a calculation.

Page 34: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

34

October 27, 2014

Now I am putting the result in nameOut but I need to specify where it is ­ it is on the document, on the info form and the field is nameOut.

Page 35: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

35

October 27, 2014

If I do not send information then I need to be specificabout the location of all the fields on the form.

Page 36: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

36

October 27, 2014

Here I sent nameOut to the function even though it was empty. In the function I assign a value to it.

Page 37: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

37

October 27, 2014

onclick I do the afunction sending aname to it.  It is received as info.

Page 38: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

38

October 27, 2014

Page 39: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

39

October 27, 2014

Page 40: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

40

October 27, 2014

I call basicHello and send it three fields of data.

I receive the data and assign the value to nameOut that is Hello concatenating withwhat is returned from the function catNames.The full name is returned and so I say Hello concatenated with the fullName returned from catNames.

Page 41: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

41

October 27, 2014

Page 42: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

42

October 27, 2014

Interesting approach where onclick I do the JavaScript shown.

Page 43: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

43

October 27, 2014

My favorite: call the basicHello and send the data.  When I have created the msg, I return it and it gets assigned to nameOut.value.

Page 44: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

44

October 27, 2014

Page 45: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

45

October 27, 2014

Page 46: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

46

October 27, 2014

I call the function calc and send it three numbers.  I then return the number I get in the formula.  The 6 gets assigned to ans.

Page 47: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

47

October 27, 2014

The difference is that I am sending up the responses tothe prompts.

Page 48: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

48

October 27, 2014

Now I am using data from text boxes and I am sending the value to the function.  Essentially at some point I need to get the value.  I can get it before I send or after I receive when I use.

Page 49: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

49

October 27, 2014

Page 50: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

50

October 27, 2014

If I do not use value, this is what I will see.

Page 51: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

51

October 27, 2014

Note that I took value offnum1 and did not use valuein the function.  This is theoutput I got.

Page 52: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

52

October 27, 2014

Page 53: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

53

October 27, 2014

Now I put the value in when I did the alert and when I did the return and it worked.

Again note that what is returned from thefunction is assigned as the result value.

Page 54: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

54

October 27, 2014

Page 55: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

55

October 27, 2014

Page 56: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

56

October 27, 2014

Page 57: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

57

October 27, 2014

Using bgColor is no longer the way to code.

Page 58: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

58

October 27, 2014

Page 59: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

59

October 27, 2014

Cancel will get me out becauseI check for user_input != nullto determine to process.

If it is null I break from the inner loop and set i to 4 so that when I return to the outer loop I will find that is is not <= 3 so I will quit.

Page 60: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

60

October 27, 2014

I can also set a flag when I break out of the inner loop and just before I go back to the outer loop check it and determine that I should break out of the outer loop if the flag is set to Y.

Page 61: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

61

October 27, 2014

I now want to change this so if the answer is wrong I willstay with it until the correct answer is entered.

Page 62: c122Oct2714.notebookcisweb.bristolcc.edu/~pgrocer/audio_smartboard14/CIS122/...of beige. onfocus can also be used to focus on individual areas of the form like a textbox. ... c122Oct2714.notebook

c122Oct2714.notebook

62

October 27, 2014

One way to do it.