/
0804.html
47 lines (42 loc) · 1.05 KB
/
0804.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<HTML>
<HEAD>
<TITLE>An event of my own!</TITLE>
<SCRIPT>
// Define a Thing object
function Thing (name, text1, text2) {
this.name = name;
this.text1 = text1;
this.text2 = text2;
}
Thing.prototype.toString = function () {
return this.name;
}
function on_Same () {
alert("The two values entered in " + this.toString() +
" are the same!");
}
function check_Same() {
if (this.text1 == this.text2) {
this.onSame();
}
}
Thing.prototype.checkSame = check_Same;
Thing.prototype.onSame = on_Same;
function createThing (name, text1, text2) {
var x = new Thing (name, text1, text2);
x.checkSame();
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE>
<FORM>
<TR><TD>Name your object:</TD><TD><input type=text name="txtName"></TD></TR>
<TR><TD>Enter first text:</TD><TD><input type=text name="txtFirst"></TD></TR>
<TR><TD>Enter second text:</TD><TD><input type=text name="txtSecond"></TD></TR>
<TR><TD></TD><TD><input type=button value="Do It!"
onClick="createThing (txtName.value, txtFirst.value, txtSecond.value);"></TD></TR>
</FORM>
</TABLE>
</BODY>
</HTML>