Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6337643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:17:25+00:00 2026-05-24T19:17:25+00:00

I am using jQuery 1.6.2 and ColdFusion 9. When a page is requested, many

  • 0

I am using jQuery 1.6.2 and ColdFusion 9.

When a page is requested, many files are included. Several files contain the jQuery document ready method. I want to set some global variables that I can use throughout the entire page. For example, I want to use these variables for my slides:

 SlideUpRate = 400;
 SlideDownRate = SlideUpRate * 2;

It seems that this works inconsistently. Is there a way to make it work consistently?

+++++++++++++++++++++++++++++++++++++++++++++++
Answer

In the index.cfm file, I set my global variables that can be used and reused in other jQuery throughout the rendered page.

<script type="text/javascript">
var SlideUpRate = 250;
var SlideDownRate = SlideUpRate * 2;
var HideRate = 250;
var ShowRate = HideRate * 2;
var ImageUnsaved = "layout/checkbox_unsaved.png";
var ImageSaved = "layout/checkbox_saved.png";
$(document).ready(function() {

   // other jQuery stuff

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:17:25+00:00Added an answer on May 24, 2026 at 7:17 pm

    Yes you can by adding them to the global namespace:

    var globalVar1;
    $(document).ready(function(){
        globalVar1 = "something";
    });
    $(document).ready(function(){
        alert(globalVar1);
    });
    

    http://jsfiddle.net/QDPAm/

    If you don’t want to pollute the global scope with multiply variables you can make an object to contain these variables:

    var vars = {};
    

    And then in your ready functions add variables to the vars object.

    $(document).ready(function(){
        vars.my_variable_1 = "something";
    });
    

    And another ready function:

    $(document).ready(function(){
        alert(vars.my_variable_1);
    });
    

    http://jsfiddle.net/aalouv/QDPAm/1/

    I cant see why your example shouldn’t work. Maybe because your are trying to access some variables before they are set?

    var vars = {};
    $(document).ready(function(){
        alert(vars.my_variable_1); // undefined
    });
    
    $(document).ready(function(){
        vars.my_variable_1 = "something";
    });
    

    http://jsfiddle.net/aalouv/QDPAm/3/

    Also creating variables without the var indicator first will add the variable to the global scope, So you can access the variable with: window or just without any namespace before.

    $(document).ready(function(){
        my_variable_1 = "something";
    });
    $(document).ready(function(){
        alert(window.my_variable_1);
        alert(my_variable_1);
    });
    

    http://jsfiddle.net/aalouv/QDPAm/2/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ColdFusion (Railo 3.3), and I have several forms using jQuery that
How do I post a form using jQuery.post() to a Coldfusion.cfc method and return
Using jQuery , how can I dynamically set the size attribute of a select
I'm looking into using Jquery to replace some of our native Coldfusion ajax functionality.
I'm using coldfusion and jquery. This is my first real go at jquery and
Using jQuery what's the way to get all elements of a queried set EXCEPT
Using jQuery I want to give a specific element the same width (or min-width
I'm using ColdFusion to return a result set from a SQL database and turn
I am using ColdFusion 9 and jQuery. I am using CFAJAXPROXY. I have am
I've got a successful call going out to a coldfusion database controller using jQuery's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.