更改多个单选按钮上的图形

时间:2014-12-22 12:02:03

标签: javascript php jquery

我有两个单选按钮。当我点击一个单选按钮时,将显示一个图表,在另一个单选按钮上单击,将显示另一个图表。

这是我尝试过的。但它不起作用:

<input type="radio" name="status" id="graph" value="graph" onclick="getValue('operatorgraph');" checked>View Graph for Revenue</input>
    <input type="radio" name="status" id="graph" value="graph" onclick="getValue('hitsgraph');">View Graph for Hits</input>
    {else}
    <input name="status" id="graph" type="hidden"></input> 
    <input name="status" id="report" type="hidden"></input>
    {/if}
   </ul>
   </div>
   <br/>

   <div class="grid_12"> 
   <div class="box"> 
   <div class="header"> 
   <div class="content" style="height: 550px;position:relative"> 
   <div style="height: 500px;" class="chart">
    <div id="chartdiv" align="center" style="position:static;border: 5px solid #3f4041">

        <script type="text/javascript">
            var chart = new FusionCharts("chart/images/FCF_MSLine.swf", "ChartId", "850", "500");
            //chart.setDataURL("datemap.xml");
            chart.setDataXML("{$productXML}");
            chart.render("chartdiv");
        </script>
      </div>
    <div id="chartdiv2" align="center" style="position:static;border: 5px solid #3f4041">

        <script type="text/javascript">
            var chart = new FusionCharts("chart/images/FCF_MSColumn2D.swf", "ChartId", "850", "500");
            //chart.setDataURL("datemap.xml");
            chart.setDataXML("{$productXML2}");
            chart.render("chartdiv2");  

        </script>
      </div>  

这是我的getValue函数:

function getValue(attr,step)
{
    if (document.getElementById('graph').checked) 
    {
        type = document.getElementById('graph').value;
    } 
    else if(document.getElementById('report').checked)
    {
        type = document.getElementById('report').value;
    }
    else
    {
        type = 'graph';
    }   

    month = document.getElementById('month').value;  
    Year = document.getElementById('year').value;

if(type == 'graph')
    {
else if(attr == 'operatorgraph')
        {
            var poststring = "event=owg&y="+Year+"&start="+start+"&end="+end;
            //alert (poststring);
            //return false;
            loadXMLDoc(poststring, onOperatorWiseGraph);
        }
        else if(attr == 'hitsgraph')
        {
            var poststring = "event=owg&y="+Year+"&start="+start+"&end="+end;
            //alert (poststring);
            //return false;
            loadXMLDoc(poststring, onOperatorWiseGraphHits);
        }
}
///////////////////////////////////

function onOperatorWiseGraph(response)
{
    //alert(response);
        //document.getElementById('app').value = '';
        var is_chrome = /chrome/i.test( navigator.userAgent );
        if(is_chrome == false)
        {
        var chart = new FusionCharts("chart/images/FCF_MSLine.swf", "ChartId", "840", "400");       
        }
        else
        {
        var chart = new FusionCharts("chart/images/FCF_MSLine.swf", "ChartId", "840", "400");   
        }       
    chart.setDataURL("appc.xml");
    chart.render("chartdiv");
}
function onOperatorWiseGraphHits(response)
{
    //alert(response);
        //document.getElementById('app').value = '';
        var is_chrome = /chrome/i.test( navigator.userAgent );
        if(is_chrome == false)
        {
        var chart = new FusionCharts("chart/images/FCF_MSColumn2D.swf", "ChartId", "840", "400");       
        }
        else
        {
        var chart = new FusionCharts("chart/images/FCF_MSColumn2D.swf", "ChartId", "840", "400");   
        }       
    chart.setDataURL("appc.xml");
    chart.render("chartdiv");
}

请告诉我哪里出错?

0 个答案:

没有答案