Hello,
I need a function to alter some variables of other function, how can I do that?
ex:
Putting c and d as global will solve the problem I think , but I would prefer to have these inside function1.
I tried var f = new function2(a,b) and then accecing by f.c and f.d but when alerting the value , it comes "undefined"
Any ideas?
Thanks in advance,
Nibbus
I need a function to alter some variables of other function, how can I do that?
ex:
Code:
function1 ()
{
var a = 7;
var b = 25;
var c;
var d;
function2 (a, b); //Does a bunch of tests and refreshes c and d values
alert(c); // --> should be 2
alert(d); // --> should be 1
}
function2 (a, b)
{
if (a < 5)
{
this.c = 0;
}
elseif (a > 10)
{
this.c = 1;
}
else
{
this.c = 2;
}
if (b < 10)
{
this.d = 0;
}
elseif (b > 20)
{
this.d = 1 ;
}
else
{
this.d = 2;
}
}
I tried var f = new function2(a,b) and then accecing by f.c and f.d but when alerting the value , it comes "undefined"
Any ideas?
Thanks in advance,
Nibbus
Comment