nishant ranjan

nishant ranjan

  • NA
  • 390
  • 0

how to call function from one js to other js

Mar 18 2014 2:36 AM
i have n no of js file say 1.js, 2.js,  3.js .......
 
all the three js contains one function say
function hello()
{
 alert("In js file 1/2/3/...n");   // as and in which js
}
 
now i have another js file say x
in x we have var id and from somewhere i am getting id value
if id=1 the hello function of js1 should be called    and alert button should popup In js file 1
if id=2 the hello function of js1 should be called   and alert button should popup In js file 2
....
....
if id=15 the hello function of js15 should be called  and alert button should popup In js file 15
if id=n the hello function of js'n' should be called  and alert button should popup In js file n
 
how can this be done. any suggestion

Answers (10)