File tree 12 files changed +106
-29
lines changed
ciw/javascript_spec_labfiles
12 files changed +106
-29
lines changed Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html>
2
2
<html>
3
- <head>
4
- <script type="text/javascript">
5
- var string1 = start;
6
- var string2 = prompt();
7
- var string3 = confirm();
8
- var string4 = end;
9
-
10
- </script>
11
- </head>
12
-
13
- <body>
14
-
15
- <script type="text/javascript">
16
- document.write("<h3>Hello, World</h3>");
17
-
18
- </script>
19
-
20
- </body>
3
+ <head>
4
+ <script type="text/javascript">
5
+ function add(arg1, arg2) {
6
+ return arg1 + arg2;
7
+ };
8
+
9
+ function subtract(arg1, arg2) {
10
+ return arg1 - arg2;
11
+ }
12
+
13
+ function multiply(arg1, arg2){
14
+ return arg1 * arg2;
15
+ };
16
+
17
+ function divide(arg1, arg2) {
18
+ return arg1 / arg2;
19
+ };
20
+ </script>
21
+ </head>
22
+ <body>
23
+ <script type="text/javascript">
24
+ document.write(add(1, 2) + "<br>");
25
+ document.write(subtract(2, 2) + "<br>");
26
+ document.write(multiply(5, 6) + "<br>");
27
+ document.write(divide(4, 6) + "<br>");
28
+
29
+ </script>
30
+ </body>
21
31
</html>
22
-
23
-
24
-
Original file line number Diff line number Diff line change 16
16
var a = 1 ;
17
17
var b = 2 ;
18
18
var c = "The answer is " + a + b ;
19
- alert ( c ) ;
19
+ alert ( c ) ; //will return 12
20
20
}
21
21
22
22
//-->
Original file line number Diff line number Diff line change 22
22
23
23
<!-- Add an onload event handler to call the function -->
24
24
25
- < body >
25
+ < body onload =" myFunction(); " >
26
26
27
27
< h3 > CIW JavaScript Specialist</ h3 >
28
28
< hr />
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ <h3>CIW JavaScript Specialist</h3>
29
29
<!-- Add an onclick event handler to call the function -->
30
30
31
31
< form name ="myForm ">
32
- < input type ="button " VALUE ="Call Function " />
32
+ < input type ="button " VALUE ="Call Function " onclick =" myFunction(); " />
33
33
</ form >
34
34
35
35
</ body >
Original file line number Diff line number Diff line change 14
14
and uses its value in the alert() method.
15
15
**************************************************************/
16
16
17
- function myFunction ( ) {
18
- alert ( "The function has been called and was passed " ) ;
17
+ function myFunction ( arg1 ) {
18
+ alert ( "The function has been called and was passed " + arg1 ) ;
19
19
}
20
20
21
21
//-->
@@ -27,7 +27,7 @@ <h3>CIW JavaScript Specialist</h3>
27
27
<!-- A form button is used to call the function.
28
28
Pass the value 'a string of text' as an argument to the function -->
29
29
< form name ="myForm " id ="myForm ">
30
- < input type ="button " value ="Call Function " onclick ="myFunction( ); " />
30
+ < input type ="button " value ="Call Function " onclick ="myFunction('a string of text' ); " />
31
31
</ form >
32
32
</ body >
33
33
</ html >
Original file line number Diff line number Diff line change 16
16
17
17
function myFunction ( arg1 ) {
18
18
alert ( "The function has been called and was passed " + arg1 ) ;
19
-
19
+ return "myFunction() return value"
20
20
}
21
21
22
22
//-->
@@ -32,7 +32,7 @@ <h3>CIW JavaScript Specialist</h3>
32
32
Wrap an alert() method around the function call.
33
33
-->
34
34
< form name ="myForm " id ="myForm ">
35
- < input type ="button " value ="call function " onclick ="myFunction('a string of text'); " />
35
+ < input type ="button " value ="call function " onclick ="alert( myFunction('a string of text') ); " />
36
36
</ form >
37
37
</ body >
38
38
</ html >
Original file line number Diff line number Diff line change
1
+ <html>
2
+ <head>
3
+ <script type="text/javascript">
4
+
5
+ </script>
6
+ </head>
7
+ <body>
8
+ <script type="text/javascript">
9
+ </script>
10
+ </body>
11
+ </html>
12
+
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < script type ="text/javascript ">
5
+ function add ( arg1 , arg2 ) {
6
+ return arg1 + arg2 ;
7
+ } ;
8
+
9
+ function subtract ( arg1 , arg2 ) {
10
+ return arg1 - arg2 ;
11
+ }
12
+
13
+ function multiply ( arg1 , arg2 ) {
14
+ return arg1 * arg2 ;
15
+ } ;
16
+
17
+ function divide ( arg1 , arg2 ) {
18
+ return arg1 / arg2 ;
19
+ } ;
20
+ </ script >
21
+ </ head >
22
+ < body >
23
+ < script type ="text/javascript ">
24
+ document . write ( add ( 1 , 2 ) + "<br>" ) ;
25
+ document . write ( subtract ( 2 , 2 ) + "<br>" ) ;
26
+ document . write ( multiply ( 5 , 6 ) + "<br>" ) ;
27
+ document . write ( divide ( 4 , 6 ) + "<br>" ) ;
28
+
29
+ </ script >
30
+ </ body >
31
+ </ html >
Original file line number Diff line number Diff line change 7
7
//onload
8
8
< body onload = "myfunction()" >
9
9
10
+
11
+ onclick();
12
+ onblur();
13
+ onfocus();
14
+ onmouseover();
15
+ onmouseout();
16
+ onsubmit();
17
+ onreset();
18
+ onchange();
19
+ onselect();
20
+ onabort();
21
+ onerror();
22
+ onload();
23
+ onunload();
Original file line number Diff line number Diff line change
1
+ abort ( ) ;
2
+ blur ( ) ;
3
+ click ( ) ;
4
+ change ( ) ;
5
+ error ( ) ;
6
+ focus ( ) ;
7
+ load ( ) ;
8
+ mouseOver ( ) ;
9
+ mouseOut ( ) ;
10
+ reset ( ) ;
11
+ select ( ) ;
12
+ submit ( ) ;
13
+ unload ( ) ;
You can’t perform that action at this time.
0 commit comments