
Heris the javascript code.It works ffine but i would like to know what is the meaning of line this.SetData=SetData and next three lines after this(in bold) because when i remove them and try calling the functions via object I am not able to do so. Is it always necessary to do this when using function of these kind.
print("<html>
<head>
<Script language="JavaScript">
function MyClass()
{
var m_data = 15;
var m_text = "indian";
**this.SetData = SetData;
this.SetText = SetText;
this.ShowData = DisplayData;
this.ShowText = DisplayText;**
function DisplayData()
{
alert( m_data );
}
function DisplayText()
{
alert( m_text );
return;
}
function SetData( myVal )
{
m_data = myVal;
}
function SetText( myText )
{
m_text = myText;
}
}
var Obj1 = new MyClass();
var Obj2 = new MyClass();
Obj1.SetData( 30 );
Obj1.SetText( "Obj1: my cuntry" );
Obj2.SetData( 60 );
Obj2.SetText( "Obj2: my first javaScript progarm" );
Obj1.ShowData();
Obj1.ShowText();
Obj2.ShowData();
Obj2.ShowText();
</script>
</head>
</body>
</html>");
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.