hi,
I am new to oo in javascript so i am not sure if i am asking the right question.
I have a script below and its not working for some reason (and its late right now)...but could anyone point out why i am getting the error:
Error: object.changeData is not a function
<html>
<head>
<script type="text/javascript">
function myClass(ini)
{
myData=ini;
this.showdata = displaydata;
function displaydata()
{
alert(myData);
}
function changeData(newData)
{
myData= newData;
}
}
function changeState(object)
{
object.changeData('300');
object.showdata();
}
</script>
</head>
<body>
<script type="text/javascript">
var obj=new Array();
obj[0]=new myClass('0');
obj[1]=new myClass('11');
obj[2]=new myClass('22');
</script>
<input type="button" name="button" onClick="changeState(obj[0])" value="Change State">
</body>
</html>
I am new to oo in javascript so i am not sure if i am asking the right question.
I have a script below and its not working for some reason (and its late right now)...but could anyone point out why i am getting the error:
Error: object.changeData is not a function
<html>
<head>
<script type="text/javascript">
function myClass(ini)
{
myData=ini;
this.showdata = displaydata;
function displaydata()
{
alert(myData);
}
function changeData(newData)
{
myData= newData;
}
}
function changeState(object)
{
object.changeData('300');
object.showdata();
}
</script>
</head>
<body>
<script type="text/javascript">
var obj=new Array();
obj[0]=new myClass('0');
obj[1]=new myClass('11');
obj[2]=new myClass('22');
</script>
<input type="button" name="button" onClick="changeState(obj[0])" value="Change State">
</body>
</html>