<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
var a,b,c
var a1,a2,a3,a4;

    google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      function Ran(){
      
      n1 = 0;
      n2 = 0;
      n3 = 0;
      n4 = 0;
      
      var maxNum = 10;  
      var minNum = 0;  
      a1 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;  
      a2 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum; 
      a3 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum; 
      a4= Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum; 
      


    

    
          drawChart();
      }

 var a ;
 var b ;
 var c ;

function add() {
a=0;
b=0;
c=0;
var radio1=document.getElementsByName("v1");
var radio2=document.getElementsByName("v2");
var radio3=document.getElementsByName("v3");
var radio4=document.getElementsByName("v4");
 

 for(var i=0;i<radio1.length;i++){
     if(radio1.item(i).checked==true)        {
       i=i+1;

       alert(i);

if(i==1){
       a=a+1;
}
else 
    if(i==2) {
        b=b+1;
    }
    else {
        c=c+1;
    }

document.getElementById('c1').value=a;
document.getElementById('c2').value=b;
document.getElementById('c3').value=c;
                  break;
       }
   }


for(var i=0;i<radio2.length;i++){
     if(radio2.item(i).checked==true)        {
       i=i+1;
       alert(i);
       if(i==1){
       a=a+1;

}
else 
    if(i==2) {
        b=b+1;
    }
    else {
        c=c+1;
    }
document.getElementById('c1').value=a;
document.getElementById('c2').value=b;
document.getElementById('c3').value=c;
                  break;
       }
   }

for(var i=0;i<radio3.length;i++){
     if(radio3.item(i).checked==true)        {
       i=i+1;
       alert(i);
       if(i==1){
       a=a+1;

}
else 
    if(i==2) {
        b=b+1;
    }
    else {
        c=c+1;
    }
document.getElementById('c1').value=a;
document.getElementById('c2').value=b;
document.getElementById('c3').value=c;
                  break;
       }
   }
for(var i=0;i<radio4.length;i++){
     if(radio4.item(i).checked==true)        {
       i=i+1;
       alert(i);

if(i==1){
       a=a+1;
}
else 
    if(i==2) {
        b=b+1;
    }
    else {
        c=c+1;
    }

document.getElementById('c1').value=a;
document.getElementById('c2').value=b;
document.getElementById('c3').value=c;
                  break;
       }
   }


            drawChart();
        }   


        function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['1',    a1],
          ['2',      a2],
          ['3',  a3],
          ['4',  a4],

        ]);

        var options = {
          title: 'My Daily Activities'
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
<h1>1、請選擇?</h1>
<input name="v1" type="radio" value="1.1">300年             
<input name="v1" type="radio" value="1.2">400年               
<input name="v1" type="radio" value="1.3">1000年
<br>
<h1>2、請選擇?</h1>
<input name="v2" type="radio" value="1.1">300年             
<input name="v2" type="radio" value="1.2">400年               
<input name="v2" type="radio" value="1.3">1000年
<br>
<h1>3、請選擇?</h1>
<input name="v3" type="radio" value="1.1">300年             
<input name="v3" type="radio" value="1.2">400年               
<input name="v3" type="radio" value="1.3">1000年
<br>
//<h1>4、請選擇?</h1>
<input name="v4" type="radio" value="1.1">300年          
<input name="v4" type="radio" value="1.2">400年     
<input name="v4" type="radio" value="1.3">1000年
<br>


1:
<input type="text" name="FirstName" id="c1"<br><br/>
2:
<input type="text" name="address" id="c2"<br><br/>
3:
<input type="text" name="address" id="c3"<br><br/>


    <input type="button" value="submit" onclick="add()"/>
<input type="button" value="Randon" onclick="Ran()"/>

    <div id="piechart" style="width: 900px; height: 500px;"></div>

  </body>
</html>

 

arrow
arrow
    全站熱搜

    harry123168 發表在 痞客邦 留言(0) 人氣()