2016年5月20日 星期五


5/20  HTML   4個選擇 畫圓餅圖


<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

    <script type="text/javascript">

 var a,b,c;
 var n1,n2,n3,n4;

      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;
      n1 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
 n2 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
 n3 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
 n4 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;



 


     drawChart();
 }

      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;
  }
if (i==2)
  {
b=b+1;
  }
if (i==3)
  {
c=c+1;
  }
  }}

     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;
  }
if (i==2)
  {
b=b+1;
  }
if (i==3)
  {
c=c+1;
  }
  }}

     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;
  }
if (i==2)
  {
b=b+1;
  }
if (i==3)
  {
c=c+1;
  }
}}

   for(var i=0;i<radio4.length;i++)
   {
     if(radio1.item(i).checked==true)
     {
i = i+1
     alert(i);
if (i==1)
  {
a=a+1;
  }
if (i==2)
  {
b=b+1;
  }
if (i==3)
  {
c=c+1;
  }
  }}

   

document.getElementById('c1').value=a;
document.getElementById('c2').value=b;
document.getElementById('c3').value=c;
document.getElementById('c4').value=d;




      drawChart();
      }

      function drawChart() {
     
       var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['A',  n1],
          ['B',  n2],
          ['C',  n3],
 ['D',  n4],
        ]);

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

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

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>

<h1>你選了什麼?</h1>
<input name="v1" type="radio" value="300年">300年        
<input name="v1" type="radio" value="400年">400年          
<input name="v1" type="radio" value="1000年">1000年
<br>
<h1>你選了什麼?</h1>
<input name="v2" type="radio" value="300年">300年        
<input name="v2" type="radio" value="400年">400年          
<input name="v2" type="radio" value="1000年">1000年
<br>
<h1>你選了什麼?</h1>
<input name="v3" type="radio" value="300年">300年        
<input name="v3" type="radio" value="400年">400年          
<input name="v3" type="radio" value="1000年">1000年
<br>
<h1>你選了什麼?</h1>
<input name="v4" type="radio" value="300年">300年        
<input name="v4" type="radio" value="400年">400年          
<input name="v4" type="radio" value="1000年">1000年
<br>


Section1:
 <input type="text" name="FirstName" id="c1" <br><br/>

Section2:
 <input type="text" name="address" id="c2" <br></br>

Section3:
 <input type="text" name="address" id="c3" <br></br>
Section4:
 <input type="text" name="address" id="c4" <br></br>

 <input type="button" value="submit" onclick="add()"/>
 <input type="button" value="隨機變數" onclick="Ran()"/>
    <div id="piechart" style="width: 900px; height: 500px;"></div>

  </body>
</html>

2016年5月13日 星期五

5/13  HTML  你選了什麼?






















<html>

  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
 
<script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work',     11],
          ['Eat',      2],
          ['Commute',  2],
          ['Watch TV', 2],
          ['Sleep',    7]
        ]);

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

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

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
  <form action="post.php" method="post"  name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>1、你選擇什麼?</h1>
<input name="v1" type="radio" value=1>A          
<input name="v1" type="radio" value=2>B          
<input name="v1" type="radio" value=3>C
</form>
<form action="post.php" method="post"  name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>2、你選了什麼?</h1>
<input name="v2" type="radio" value="1">A
<input name="v2" type="radio" value="2">B          
<input name="v2" type="radio" value="3">C

</form>
<form action="post.php" method="post"  name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>3、你選了什麼?</h1>
<input name="v3" type="radio" value="1">A          
<input name="v3" type="radio" value="2">B            
<input name="v3" type="radio" value="3">C
</form>
<form action="post.php" method="post"  name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>4、你選了什麼?</h1>
<input name="v4" type="radio" value="1">A          
<input name="v4" type="radio" value="2">B            
<input name="v4" type="radio" value="3">C
</form>
    <div id="piechart" style="width: 900px; height: 500px;"></div>
  </body>
  <input type="button" value="送出" onclick=("drawChart")/>
</html>

2016年5月6日 星期五

5/6  HTML 加法


http://www.kangting.tw/2012/07/htmljavascriptcss.html