[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tip: drawing chart without reload the page



 
    

<SCRIPT LANGUAGE="JavaScript">

var chartcode;
var unitType, numunits;
var today = new Date();

function UpdateGraph()
{
        if (document.Chart && document.ChartForm)
        {
                var companies = '';
                var numdays;
                var newsrc;
                var t;

                unitType = document.ChartForm.Units.options[document.ChartForm.Units.selectedIndex].value;
                numunits = document.ChartForm.Periods.options[document.ChartForm.Periods.selectedIndex].value;
                companies = document.ChartForm.Tickers.value + '-' + document.ChartForm.Indices.options[document.ChartForm.Indices.selectedIndex].value;

// t stands for 'type' and can be 'r' for relative or 'c' for candlestick.
// There is no particular reason for having index-only graphs as relative so please yourself either way.

                t = (document.ChartForm.Tickers.value == '') ? 'r' : 'c';

                if (unitType == 'd')
                        numdays = numunits;
                else
                if (unitType == 'w')
                        numdays = numunits * 7 - today.getDay();
                else
                if (unitType == 'm')
                        numdays = numunits * 30 - today.getDate();
                else
                        numdays = numunits * 30 - today.getDate();

                newsrc = 'http://www.equitycafe.com.au/graphxchange/abc/chart/charts2.exe?s=' + companies + '&p=' + unitType + '&n=' + numdays + '&t=' + t;

                if (document.Chart.src != newsrc)
                        document.Chart.src = newsrc;

                return false;
        }
        else
                return true;
}

<FORM METHOD="POST"
 ACTION="http://www.equitycafe.com.au/ec/charts.cfm?ecmode=draw";
 ONSUBMIT="if (document.Chart) return UpdateGraph(); else return true;"
 NAME="ChartForm">
</FORM>

<IMG NAME="Chart" SRC="/news/img/invisible.gif" WIDTH="580" HEIGHT="395">


Source: <http://www.abc.net.au/news/business/chart/default.htm>

Google