Hi all again,
i have read tutorial about javascript classical inheritance Douglas Crockford wrote. But i did an example for the reason practizing as it showed in his page http://www.crockford.com/javascript/inheritance.html
for ex i did the following example.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>

function Parenizor(value) {
    this.setValue(value);
}

Parenizor.method('setValue', function (value) {
    this.value = value;
    return this;
});

Parenizor.method('getValue', function () {
    return this.value;
});

Parenizor.method('toString', function () {
    return '(' + this.getValue() + ')';
});
myParenizor = new Parenizor(0);
myString = myParenizor.toString();
alert(myString);



</script>

</head>

<body>
</body>
</html>

But it doesnt work. it shows an error. maybe wherever i did mistake. If possible please help to find out problem. Thanks inadvance for attention

what error does it show?

it shows nothing. but it must show an alert box

I don't see your function actually being called anywhere.

I don't see your function actually being called anywhere.

i called it here like this
from line 24 to 26

myParenizor = new Parenizor(0);
myString = myParenizor.toString();
alert(myString);

and where do you call that? I see no 'onClick', no 'onLoad', no jQuery code that's used to call your code when the page loads.

I've never used inheritance in javascript, so I'm not sure what the issue is, but I doubt that code is ran automatically

and where do you call that? I see no 'onClick', no 'onLoad', no jQuery code that's used to call your code when the page loads.

I've never used inheritance in javascript, so I'm not sure what the issue is, but I doubt that code is ran automatically

can you show me how to use it? But even if i call it with onclick or smth like that. it will not show anything

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.