+ All Categories
Home > Documents > Kingscliff & Murwillumbah IT – More fun than you imagine! · 1. 2. 3. 4. Random Words 5.

Kingscliff & Murwillumbah IT – More fun than you imagine! · 1. 2. 3. 4. Random Words 5.

Date post: 06-Aug-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
78
Transcript
Page 1: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 2: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 3: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 4: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 6: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 7: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 8: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 10: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 11: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 12: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 13: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 14: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 15: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 16: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 17: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Just a Generic Page</title>

<script>

setTimeout(wakeUp, 5000);

function wakeUp () {

alert("Hello, are you still there?");

}

</script>

</head>

<body>

<h1>Page Heading</h1>

<p>just some dummy text to fill in the space until something

better comes along</p>

</body>

</html>

Page 18: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Just a Generic Page</title>

<script src="js/scripting.js" type="text/javascript"></script>

</head>

<body>

<h1>Page Heading</h1>

<p>just some dummy text to fill in the space until something

better comes along</p>

</body>

</html>

setTimeout(wakeUp, 5000);

function wakeUp () {

alert("Hello, are you still there?");

}

Page 19: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

<H1> I’m a heading</H1>

<P> I’m a paragraph of text.</P>

H1{

font-size:90px;

}

P{

font-size:8px;

}

var a = 10;

var b = 2;

var c = a+b;

setTimeout(wakeUp, 5000);

function wakeUp () {

alert(a + ' + ' + b +'=' +c);

}

Page 20: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

var car = “Ferrari’;

var carMoving = “false”;

if (carMoving == true) {

alert(“Watch out”);

} else{

alert(“Walk”);

}

var car = “Ferrari”;

var carMoving = false;

if (carMoving == true) {

alert(“Watch out”);

} else{

alert(“Walk”);

}

Page 21: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

var drink = “Fanta”;

var joesFavouriteDrink =

‘Milk’;

var dairy = true;

if (dairy == true) {

alert(“Keep an eye on

Joe”);

}else{

alert(“Ask for a” + drink

);

}

var drink = Fanta;

var

joe’sFavouriteDrink =

‘Milk’

var dairy = ‘true’;

if (Dairy == true) {

alert(“Keep an eye on

Joe”);

} else{

alert(“Ask for a” +

drink );

}

var car = “Ferrari’;

var carMoving = “false”;

if (carMoving == true) {

alert(“Watch out”);

}else{

alert(“Walk”);

}

var drink = Fanta;

var joe’sFavouriteDrink = ‘Milk’

var dairy = ‘true’;

if (Dairy == true) {

alert(“Keep an eye on Joe”);

}else{

alert(“Ask for a” + drink );

}

Page 22: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html>

2. <html lang="en">

3. <head>

4. <meta charset="utf-8">

5. <title>My First Java Script Page</title>

6. </head>

7. <body>

8. <script type="text/javascript">

9. <!--

10. document.write("Hello there.");

11 //-->

12. </script>

13. <noscript>Your browser does not support JavaScript or JavaScript isn’t

enabled, please upgrade your browser or enable JavaScript to view the

content</noscript>

14. </body>

15.</html>

Page 23: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 24: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 26: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 28: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 29: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html>

2. <html lang="en">

3. <head>

4. <meta charset="utf-8">

5. <title>My First Java Script Page</title>

6. </head>

7. <body>

8. <script type="text/javascript">

9. <!--

10. document.write("Hello there.");

11. //-->

12. </script>

13. <noscript>Your browser does not support JavaScript, please enable

Javascript to view the content</noscript>

14. </body>

15.</html>

Page 30: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 31: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 32: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset=”utf-8"> 5. <title>My First Java Script Page</title> 6. </head> 7. <body> 8. <script type="text/javascript"> 9. str = "Hello World"; 10. document.write(str); 11. </script> 12. </body> 13. </html>

Page 33: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 34: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 35: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 36: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset="utf-8"> 5. <title>Concatenating Strings</title> 6. </head> 7. <body> 8. <script type="text/javascript"> 9. str1 = "Hello"; 10. str2 = "Kevin, have a nice day"; 11. str3 = str1 + " " + str2; 12. document.write(str3); 13. </script> 14. </body> 15. </html>

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset="utf-8"> 5. <title>Concatenating Strings</title> 6. </head> 7. <body> 8. <script type="text/javascript"> 9. str1 = "Hello"; 10. str2 = "Kevin, have a nice day"; 11. str3 = str1 + " " + str2; 12. document.write(str3); 13. </script> 14. </body> 15. </html>

Page 37: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset=”utf-8"/> 5. <title>Variables</title> 6. </head> 7. <body> 8. <script type="text/javascript"> 9. num1 = 3; 10. num2 = 6; 11. sum = num1 + num2; 12. document.write(num1 + " + " + num2 + " = " + sum); 13. </script> 14. </body> 15. </html>

Page 38: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 41: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 42: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset="utf-8">

5. <title>Add 2 Fields</title> 6. </head> 7. <body> 8. <form id="calculate" name="calculate" method="post"> 9. <p> 10. <label for="numberOne">First Number:</label> 11. <input type="text" name="numberOne"

id="numberOne"> 12. </p> 13. <p> 14. <label for="numberTwo">Second Number:</label> 15. <input type="text" name="numberTwo"

id="numberTwo"> 16. </p> 17. <p> 18. <label for="answer">Answer:</label> 19. <input type="text" name="answer" id="answer"

readonly> 20. </p> 21. </form> 22. </body>

23. </html>

1. <script type="text/javascript"> 2. function findAnswer(){ 3. var num1 = document.forms['calculate'].numberOne.value; 4. var num2 = document.forms['calculate'].numberTwo.value; 5. var answerIt = num1 + num2; 6. document.forms['calculate'].answer.value = answerIt;

7. } 8. </script>

Page 43: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <p> 2. <input type="button" name="answerButton" onClick="findAnswer()"

id="answerButton" value="Calculate Answer">

3. </p>

Page 44: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 45: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 46: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 47: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 48: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 49: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset="utf-8">

5. <title>Add 2 Fields</title> 6. </head> 7. <body> 8. <form id="calculate" name="calculate" method="post"> 9. <p> 10. <label for="numberOne">First Number:</label> 11. <input type="number" name="numberOne"

id="numberOne"> 12. </p> 13. <p> 14. <label for="numberTwo">Second Number:</label> 15. <input type="number" name="numberTwo"

id="numberTwo"> 16. </p> 17. <p> 18. <label for="answer">Answer:</label> 19. <input type="number" name="answer" id="answer"

readonly> 20. </p> 21. </form> 22. </body>

23. </html>

1. <script type="text/javascript"> 2. function findAnswer(){ 3. var num1 = Number(document.forms['calculate'].numberOne.value); 4. var num2 = Number(document.forms['calculate'].numberTwo.value); 5. var answerIt = num1 + num2; 6. document.forms['calculate'].answer.value = answerIt;

7. } 8. </script>

Page 50: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <p> 2. <input type="button" name="answerButton" onClick="findAnswer()"

id="answerButton" value="Calculate Answer">

3. </p>

Statement 1

Statement 2

Statement 3

Page 51: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

Statement 1

Statement 3 Statement 2

Statement 4

Condition

Statement 1

Statement 2

Check

Condition

True

False

Page 52: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 53: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 54: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

No

Start

Read

Mark

Is Mark text

or <0 or

>100

Alert

Error

Is Mark

<50

End

Print Mark

(Fail)

Print Mark

(Distinction)

Yes

Yes

No

Page 55: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset="utf-8"> 5. <title>Grades</title> 6. <script type="text/javascript"> 7. function displaymarks() { 8. var mark = Number(document.getElementById("mark").value); 9. if(isNaN(mark) == true || mark < 0 || mark > 100 ) { 10. alert("Mark is not a valid number between 0 and 100"); 11. }else{ 12. if (mark >= 50) { // if mark is a number greater or equal to

50 but lower than 100 13. document.getElementById("result").innerHTML ="<font color =

'green'>You have received a Pass</font>"; 14. } 15. else if (mark < 50) { // if mark is a lower than 50 but

higher than zero 16. document.getElementById("result").innerHTML ="You have

received a Fail"; 17. } 18. } 19. } 20. </script> 21. </head> 22. <body> 23. <form id="form1" name="form1" method="post" action=""> 24. <p> 25. <label for="Mark"> Mark out of 100:</label> 26. <input type="text" name="mark" id="mark" /> 27. </p> 28. <p> 29. <label for="Grade"></label> 30. <input type="button" name="grade" id="grade" value="Grade"

onclick="javascript: displaymarks()" /> 31. </p> 32. </form> 33. <strong><span id="result"></span></strong> 34. </body>

35. </html> 36.

Page 56: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

if(isNaN(mark) == true || mark < 0 || mark > 100 ) {

Page 57: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

if (condition1) {

block of code to be executed if condition1 is true

} else if (condition2) {

block of code to be executed if the condition1 is false

and condition2 is true

} else {

block of code to be executed if the condition1 is false

and condition2 is false

}

1. if(isNaN(mark) == true || mark < 0 || mark > 100 ) { 2. alert("Mark is not a valid number between 0 and 100"); 3. }else{ 4. if (mark >= 50) { // if mark is a number greater or equal to 50 but lower

than 100 5. document.getElementById("result").innerHTML ="<font color = 'green'>You

have received a Pass</font>"; 6. } 7. else if (mark < 50) { // if mark is a lower than 50 but higher than zero 8. document.getElementById("result").innerHTML ="You have received a Fail"; 9. }

10. }

Page 58: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

if (condition) {

block of code to be executed if the condition is true

} else {

block of code to be executed if the condition is false

}

if (bidders >= 10) {

alert("This is a great property who wants to buy?");

}else if (bidders == 3 {

alert("The bidding is getting tough");

} else if (bidders == 2) {

alert("Only two bidders on this this great property");

} else if (bidders == 1) {

alert("Going once, Going twice, GONE");

} else {

alert("The property has been passed in at auction");

}

Page 59: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 60: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

while (i < 10) {

document.write("The number is " + i);

i++;

}

Page 61: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 62: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

var results = [55, 75, 66, 39, 60, 88, 74, 60, 57, 81, 93, 52, 70, 49, 89];

var student2 = results[2];

alert(“Student two’s result is “ + student2);

var students =[ ];

var students =[“Fred”, “Ginger”, “Joan”, “Jackie”, “Bruce”,

“Melissa”, “Cheryl”, “Oxnard”];

Page 63: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

var students =[“Fred”, “Ginger”, “Joan”, “Jackie”, “Bruce”,

“Melissa”, “Cheryl”, “Oxnard”];

students[5]=“Max”;

var students =[“Fred”, “Ginger”, “Joan”, “Jackie”, “Bruce”,

“Max”, “Cheryl”, “Oxnard”];

Page 64: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html lang="en"> 3. <head> 4. <title>Random Words</title> 5. <meta charset="utf-8"> 6. <script> 7. function makePhrases() { 8. var words1 = ["1", "2", "3", "4", "5"]; 9. var words2 = ["tweeting", "bouncing", "mooing", "honking",

"quacking"]; 10. var words3 = ["birds", "kangaroos", "cows", "swans", "ducks"]; 11. var rand1 = Math.floor(Math.random() * words1.length); 12. var rand2 = Math.floor(Math.random() * words2.length); 13. var rand3 = Math.floor(Math.random() * words3.length); 14. var phrase = words1[rand1] + " " + words2[rand2] + " " +

words3[rand3]; 15. alert(phrase); 16. } 17. makePhrases(); 18. </script> 19. </head> 20. <body> 21. </body>

22. </html>

var emptyArray = [ ];

Page 65: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

var a = [1, 2, 3] a[10] a[-1]

myArray[myArray.length - 1]

Page 66: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 67: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset="utf-8"> 5. <title>Grades</title> 6. <script type="text/javascript"> 7. var marks = []; // create the array globally 8. function displaymarks() { 9. var mark = Number(document.getElementById("mark").value); 10. if(isNaN(mark) == true || mark < 0 || mark >100 ) { 11. alert("Mark is not a valid number from 1 to 100"); 12. }else{ 13. marks.push(mark); // add mark to end of array 14. var display = ""; // declare and intialise display string 15. var sum = 0; // temporary running total field 16. var avg = 0; // temporary avgerage field 17. for (i = 0; i < marks.length; i++) { 18. sum += marks[i]; // total all marks in array together; 19. display = display + "Mark " + (i + 1) + ": " + marks[i] + "%

(" + marksToGrade(marks[i]) + ") <br/>"; 20. } 21. avg = sum / marks.length; // calculate the average 22. display = display + "<br/>Average is " + avg.toFixed(2) + "% ("

+ marksToGrade(avg) + ") <br/>"; 23. document.getElementById("result").innerHTML = display;

//display the result 24. document.getElementById("mark").value = ""; // clear

the input box 25. } 26. } 27. function marksToGrade(mark){ 28. var grade; 29. if (mark < 50) { 30. grade = "Fail"; 31. } 32. else if (mark < 70) { 33. grade = "Pass"; 34. } 35. else if (mark < 83){ 36. grade = "Credit"; 37. }else{ 38. grade = "Distinction"; 39. } 40. return grade; 41. } 42. </script> 43. </head> 44. <body> 45. <form id="form1" name="form1" method="post" action=""> 46. <p> 47. <label for="Mark">Mark out of 100:</label> 48. <input type="text" name="mark" id="mark" /> 49. </p> 50. <p> 51. <label for="Grade"></label>

Page 69: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 70: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 71: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

1. <!doctype html> 2. <html> 3. <head> 4. <meta charset="utf-8"> 5. <title>Grades</title> 6. <script type="text/javascript"> 7. function displaymarks() { 8. var mark = Number(document.getElementById("Mark").value); 9. if(NaN(mark) == true || mark < 0 || mark >100 ) { 10. alert("Mark is not a valid number between 0 and 100"); 11. }else{ 12. if (mark >= 50) { // if mark is a number greater or equal to 50 but lower than

100 13. document.getElementById("resutl").innerHTML ="<font color = 'green'>You

have received a Pass</font>"; 14. } 15. else if (mark < 50) { // if mark is a lower than 50 but higher than zero 16. document.getElementById("result).innerHTML ="You have received a Fail";} 17. } 18. } 19. </script> 20. </head> 21. <body> 22. <form id="form1" name="form1" method="post" action=""> 23. <p> 24. <label for="Mark"> Mark out of 100:</label> 25. <input type="text" name="mark" id="marK" /> 26. </p> 27. <p> 28. <label for="Grade"></label> 29. <input type="button" name="grade" id="garde" value="Grade"

onclick="javascript: dispalymarks()" /> 30. </p> 31. </form> 32. <strong><span id="result"></span></strong> 33. </body> 34. </html>

Page 72: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

document.getElementById("result).innerHTML ="You have received a

Fail";}

Page 74: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 76: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.
Page 77: Kingscliff & Murwillumbah IT – More fun than you imagine! · 1.  2.  3.  4. Random Words 5.

Recommended