I'm trying to develope a Javascript fuction that will show the current funds raised. I'm needing to be able to specify a Start Dollar Amount ($0), Goal Dollar Amount ($XXX,XXX,XXX), and a Current Dollar Amount ($XX,XXX). I would like to have this show up as numerical amount and then also a percentage. I know I can predefine the amounts in the javascript itself but is there a way to have the javascript read a .txt file that hase the amounts in it? I have a working script that already does the above but not the .txt file portion. I'm hoping someone can help me. The site I'm working on is completely coded in ASP if that helps any.

<html>
    <head>
        <title>Demo Counter</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            (function($) {
                $.fn.countTo = function(options) {
                    // merge the default plugin settings with the custom options
                    options = $.extend({}, $.fn.countTo.defaults, options || {});

                    // how many times to update the value, and how much to increment the value on each update
                    var loops = Math.ceil(options.speed / options.refreshInterval),
                        increment = (options.Current - options.Start) / loops;

                    return $(this).each(function() {
                        var _this = this,
                            loopCount = 0,
                            value = options.Start,
                            interval = setInterval(updateTimer, options.refreshInterval);

                        function updateTimer() {
                            value += increment;
                            loopCount++;
                            $(_this).html(value.toFixed(options.decimals));

                            if (typeof(options.onUpdate) == 'function') {
                                options.onUpdate.call(_this, value);
                            }

                            if (loopCount >= loops) {
                                clearInterval(interval);
                                value = options.to;

                                if (typeof(options.onComplete) == 'function') {
                                    options.onComplete.call(_this, value);
                                }
                            }
                        }
                    });
                };

                $.fn.DifferenceTo = function(option2) {

                };

                $.fn.countTo.defaults = {
                    Start: 0,  // the number the element should start at
                    End: 100,  // the number the element should end at
                    Current: 50, // the current number
                    speed: 1000,  // how long it should take to count between the target numbers
                    refreshInterval: 100,  // how often the element should be updated
                    decimals: 0,  // the number of decimal places to show
                    onUpdate: null,  // callback method for every time the element is updated,
                    onComplete: null,  // callback method for when the element finishes updating
                };
            })(jQuery);

        </script>
        <link type="text/css" rel="stylesheet" media="screen" href="style.css" />
    </head>
    <body>
        <script type="text/javascript"><!--
            jQuery(function($) {
                $('.timer').countTo({
                    Start: 0,
                    End: 2500,
                    Current: 1250,
                    speed: 5000,
                    refreshInterval: 50,
                    onComplete: function(value) {
                        console.debug(this);
                    }
                });
            });
        //--></script>
        <span class="timer"></span>
        <p>We are $<span class="deficit"></span> from our goal.  Please help us reach it.</p>
    </body>
</html>

You can have a look at this snippet from Microsoft website to get an idea of achieving what you want. Check it out

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.