How can I use a variable to call a .js file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How can I use a variable to call a .js file

jaycssjaycss Posts: 8Member
I need some help, here.
I need to call this .js file automatically,
not with an onClick function.
How can I call a .js file in a situation like the following:
----------------------------------

var cnt = "2";


----------------------------------
This call should load a .js file named "21.js".
I have tried all kinds of stuff. Now my mind is mush.
Please help, if you can.

Comments

  • jaycssjaycss Posts: 8Member
    : I need some help, here.
    : I need to call this .js file automatically,
    : not with an onClick function.
    : How can I call a .js file in a situation like the following:
    : ----------------------------------
    :
    : var cnt = "2";
    :
    :
    : ----------------------------------
    : This call should load a .js file named "21.js".
    : I have tried all kinds of stuff. Now my mind is mush.
    : Please help, if you can.
    :


  • xapisxapis Posts: 5Member
    : : I need some help, here.
    : : I need to call this .js file automatically,
    : : not with an onClick function.
    : : How can I call a .js file in a situation like the following:
    : : ----------------------------------
    : :
    : : var cnt = "2";
    : :
    : :
    : : ----------------------------------
    : : This call should load a .js file named "21.js".
    : : I have tried all kinds of stuff. Now my mind is mush.
    : : Please help, if you can.
    : :
    :
    :

    I believe all you should have to do is the following:





    And 21.js includes:


    alert("Hello there!");


    Remember 21.js must be in the same directory as your calling file. Otherwise use the following:






  • jaycssjaycss Posts: 8Member
    : : : I need some help, here.
    : : : I need to call this .js file automatically,
    : : : not with an onClick function.
    : : : How can I call a .js file in a situation like the following:
    : : : ----------------------------------
    : : :
    : : : var cnt = "2";
    : : :
    : : :
    : : : ----------------------------------
    : : : This call should load a .js file named "21.js".
    : : : I have tried all kinds of stuff. Now my mind is mush.
    : : : Please help, if you can.
    : : :
    : :
    : :
    :
    : I believe all you should have to do is the following:
    :
    :
    :
    :
    :
    : And 21.js includes:
    :
    :
    : alert("Hello there!");
    :
    :
    : Remember 21.js must be in the same directory as your calling file. Otherwise use the following:
    :
    :
    :
    :
    :
    :
    Thanks for the effort. This has all got to be dynamic. By that I mean, not HARD CODED.

  • jaycssjaycss Posts: 8Member
    : I need some help, here.
    : I need to call this .js file automatically,
    : not with an onClick function.
    : How can I call a .js file in a situation like the following:
    : ----------------------------------
    :
    : var cnt = "2";
    :
    :
    : ----------------------------------
    : This call should load a .js file named "21.js".
    : I have tried all kinds of stuff. Now my mind is mush.
    : Please help, if you can.
    :
    I will post the answer later tonight for anyone that might want to know how to do this. It ended up being pretty easy.

  • jaycssjaycss Posts: 8Member
    : I need some help, here.
    : I need to call this .js file automatically,
    : not with an onClick function.
    : How can I call a .js file in a situation like the following:
    : ----------------------------------
    :
    : var cnt = "2";
    :
    :
    : ----------------------------------
    : This call should load a .js file named "21.js".
    : I have tried all kinds of stuff. Now my mind is mush.
    : Please help, if you can.
    :
    This how to do it. I even got it to loop thru a 'for' loop and load 4 different .js files. It will read the following files:
    ('11.js' & '21.js' & '31.js' & '41.js')
    -------------











Sign In or Register to comment.