SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Sep 2002
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple JavaScript Question

    I'm sure this is a pretty simple question to answer so help!

    I am wanting to make a config.js file that holds all the global scope variables. Then I want other files to use these variables in the web page. Is it possible that the get_stores_AJAX.js and the form-validation3.js have access to the variables in the config.js? If not is it even possible to do something like I am suggesting? If it is possible how do you do it?

    HTML Code:
    <script type="text/javascript" src="js/config.js"></script>
    <script type="text/javascript" src="/includes/global/js/get_stores_AJAX.js"></script>
    <script type="text/javascript" src="js/form-validation3.js"></script>
    config.js
    Code:
    // these variables are needed by the get_stores_AJAX.js file
    var theForm;
    var xhr = false;
    var region = false;
    var store = false;
    var app_name = 'pl_demo';
    
    // these variables are needed by the rest of the JavaScript code
    var submitBtn;
    var tm_first_name = false;
    var tm_last_name = false;
    var date = false;
    var month = '';
    var day = '';
    var year = '';
    var month_name = new Array(12);

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should be fine exactly as you have shown.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •