1
+ var x1 = document . getElementById ( 'x1' ) . innerHTML ;
2
+ var x2 = document . getElementById ( 'x2' ) . innerHTML ;
3
+ var x3 = document . getElementById ( 'x3' ) . innerHTML ;
4
+ var x4 = document . getElementById ( 'x4' ) . innerHTML ;
5
+
6
+ var btn = document . getElementById ( 'btn' ) ;
7
+
8
+ function changeButton ( ) {
9
+ btn . innerHTML = "Return" ;
10
+ btn . setAttribute ( "onclick" , "returnValues();" ) ;
11
+ }
12
+
13
+ function returnValues ( ) {
14
+ document . getElementById ( 'x1' ) . innerHTML = x1 ;
15
+ document . getElementById ( 'x2' ) . innerHTML = x2 ;
16
+ document . getElementById ( 'x3' ) . innerHTML = x3 ;
17
+ document . getElementById ( 'x4' ) . innerHTML = x4 ;
18
+
19
+ btn . innerHTML = "Result" ;
20
+ btn . setAttribute ( "onclick" , "showResult();" ) ;
21
+ }
22
+
23
+ function showResult ( ) {
24
+ var result = "Fiat" + 147 ;
25
+
26
+ document . getElementById ( 'x1' ) . innerHTML = 'x = ' + result ;
27
+ //-----------------------------------------------------------------
28
+ result = "Fiat" + 1 + 4 + 7 ;
29
+
30
+ document . getElementById ( 'x2' ) . innerHTML = 'x = ' + result ;
31
+ //-----------------------------------------------------------------
32
+ result = 147 + "Fiat" ;
33
+
34
+ document . getElementById ( 'x3' ) . innerHTML = 'x = ' + result ;
35
+ //-----------------------------------------------------------------
36
+ result = 1 + 4 + 7 + "Fiat" ;
37
+
38
+ document . getElementById ( 'x4' ) . innerHTML = 'x = ' + result ;
39
+ //-----------------------------------------------------------------
40
+ changeButton ( ) ;
41
+ }
0 commit comments