程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> js-如何把頁面Table的值傳到jQuery裡?

js-如何把頁面Table的值傳到jQuery裡?

編輯:編程綜合問答
如何把頁面Table的值傳到jQuery裡?
 <!doctype html>
<html>
    <head>
        <script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
        <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
        <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/exporting.js"></script>
        <script type="text/javascript">
            $(function (){
                $('#container').highcharts({
                    title: {
                        text: '?',
                    },
                    xAxis: {
                        categories: []
                    },
                    yAxis: {

                        title: {
                            text: '數據'
                        },
                    },
                    series: [{
                        name: '?',
                        data: []
                    }]
                });
            });
        </script>
        <script type="text/javascript">
            $(function () {
                $('#container2').highcharts({
                    title: {
                        text: '鏈球菌毒素O',
                    },
                    xAxis: {
                        categories: []
                    },
                    yAxis: {

                        title: {
                            text: '數據'
                        },
                    },
                    series: [{
                        name: 'SBASO',
                        data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
                    }]
                });
            });
        </script>
    </head>
    <body>
        <h1>曲線圖</h1>
        <!-- 第一個空圖 -->
        <div id="container" style="width:300px;height:300px;float:left;"></div>
        <!-- 第二個有數據的圖 -->
        <div id="container2" style="width:300px;height:300px;float:left;"></div>
        <table border="1" align="left">
            <tr>
                <td>CName</td>
                <td>EName</td>
                <td>Time</td>
                <td>Date</td>               
            </tr>
            <tr>
                <td>血小板</td>
                <td>HPLT</td>
                <td>1</td>
                <td>7.0</td>                
            </tr>
            <tr>
                <td>血小板</td>
                <td>HPLT</td>
                <td>2</td>
                <td>6.9</td>                
            </tr>
            <tr>
                <td>血小板</td>
                <td>HPLT</td>
                <td>3</td>
                <td>9.5</td>                
            </tr>
        </table>
    </body>
</html>

大神們!直接把源碼粘上就可以運行

最佳回答:


 <!doctype html>
<html>
    <head>
        <script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
        <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
        <script type="text/javascript">
               var chart ;
            $(function (){
                chart = new Highcharts.Chart({
                    chart: {  
                        renderTo: 'container'
                    },
                    title: {
                        text: '?',
                    },
                    xAxis: {
                        categories: []
                    },
                    yAxis: {
                        title: {
                            text: '數據'
                        },
                    },
                    series: []
                });
            });
            function show(){
                var trs = $('table tr');
                var datas=[];
                var map={};
                for(var i=1;i<trs.length;i++){
                     var nams = $('td:first',trs[i]).html();
                     var value = $('td:last',trs[i]).html();
                     if(typeof map[nams]=='undefined'){
                          var pos = datas.length;
                          map[nams] = pos;
                          datas[pos]={name:nams,data:[]};
                     }
                     datas[map[nams]]["data"].push(Number(value));
                }
                var series=chart.series;  
                if(series.length > 0){
                   series[0].remove(false); 
              }
              var d = datas[0];
              chart.addSeries(d);
              chart.setTitle({text:d.name});
              chart.redraw();
            }
        </script>
        <script type="text/javascript">
            $(function () {
                new Highcharts.Chart({
                      chart: {  
                        renderTo: 'container2'
                    },
                    title: {
                        text: '鏈球菌毒素O',
                    },
                    xAxis: {
                        categories: []
                    },
                    yAxis: {

                        title: {
                            text: '數據'
                        },
                    },
                    series: [{
                        name: 'SBASO',
                        data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
                    }]
                });
            });
        </script>
    </head>
    <body>
          <input type='button' onclick='show()' value='顯示表格數據'/>
        <h1>曲線圖</h1>
        <!-- 第一個空圖 -->
        <div id="container" style="width:300px;height:300px;float:left;"></div>
        <!-- 第二個有數據的圖 -->
        <div id="container2" style="width:300px;height:300px;float:left;"></div>
        <table border="1" align="left">
            <tr>
                <td>CName</td>
                <td>EName</td>
                <td>Time</td>
                <td>Date</td>               
            </tr>
            <tr>
                <td>血小板</td>
                <td>HPLT</td>
                <td>1</td>
                <td>7.0</td>                
            </tr>
            <tr>
                <td>血小板</td>
                <td>HPLT</td>
                <td>2</td>
                <td>6.9</td>                
            </tr>
            <tr>
                <td>血小板</td>
                <td>HPLT</td>
                <td>3</td>
                <td>9.5</td>                
            </tr>
        </table>
    </body>
</html>
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved