Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling a function from another function :)

Status
Not open for further replies.

TurboSRT4

Programmer
Nov 23, 2009
47
US
Hi probably a new b question but whatever im new to javascript any way...

I have a function.....

function myFunction(){
var myVar = 'true';
}
how do i make it so if myVar == 'true' then to call myOtherFunction()

so like
myFunction(){
var myVar = 'true';
if(myVar == 'true'){
run myOtherFunction('pass1','pass2');
}
}

thank you
 
Just call the function assuming its defined before the first one.

Code:
function myfirst(arg1,arg2){
...

}

function mysecond(){
var myVar='true';

if(myVar=='true'){
myfirst("Hello","World");
}

}

Your second function would need to output to screen for you to know it ran. If it returns a value you can assign it to another variable such as:

var myVar2=myfirst("Hello","World");

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
remember there isn't a javascript keyword 'run', you just type the name of the function, include any arguments between the brackets (comma separated) and put a semicolon at the end.

it's that simple.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top