2016年6月3日 星期五

6/3 亂數不重複

<html>
 <head>
  <title>HTML</title>
 </head>
 <body>
  <script>
   var balls = new Array(10);
   var i=0,j=0,k=0;
   for(i=0;i<10;i++)
   {
    balls[i]=i+1;
   }
   for(i=1;i<=1000;i++)
   {
    j=Math.floor(Math.random()*9);
    k=Math.floor(Math.random()*9);
    balls[9]=balls[j];
    balls[j]=balls[k];
    balls[k]=balls[9];
   }
   document.write(balls[0]+","+balls[1]+","+balls[2]+",");
  </script>
 </body>
</html>

4/29

4/29 

貼在WORDPAD裡 檔名改test.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>第一支javaScript</title>
</head>
<body>
<h2>document.write用法</h2>
 <Script type ="text/javascript">
  document.write("Hello world!!");
 </Script>
</body>
</html>




<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>第一支javaScript</title>
</head>
<body>
<input type="checkbox" name="interest" value="單 打 獨 鬥" id="1"><label for="1">單 打 獨 鬥---------------</label><label for="demoradio_1">

<div class="qheader">
1) What is the difference between a jungle and a rain forest?</div>
<div class="qselections">
<input type="radio" value="a" name="question1">a) No difference. Simply two different ways in referring to the same thing.<br>
<input type="radio" value="b" name="question1">b) A jungle in general receives less rain than a rain forest.<br>
<input type="radio" value="c" name="question1">c) A jungle refers to the thickest area of a rain forest<br>
<input type="radio" value="d" name="question1">d) A jungle and a rain forest each contain their own group of distinct plants and animals.<br>
</div>

<br>

<h2>document.write用法</h2>
 <Script type ="text/javascript">
  document.write("Hello world!!");
 </Script>
</body>
</html>

2016年6月2日 星期四

5/20

5/20

<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);
      var a,b,c;
      a=0;
      b=0;
      c=0;
      function add() {
   
 var radio1 = document.getElementsByName("v1");
 var radio2 = document.getElementsByName("v2");
 var radio3 = document.getElementsByName("v3");


   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;
  }


   
     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;
  }
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;

 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;
  }
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;
 break;
     }
   }







      drawChart();
      }

      function drawChart() {
     
       var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work',     a],
          ['Eat',      b],
          ['Commute',  c],
        ]);

        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>


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

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

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


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

  </body>
</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);
      var a,b,c;
      a=0;
      b=0;
      c=0;
var n1=n2=n3=n4=0;

function Random() {

var maxNum = 4;
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() {
   
 var radio1 = document.getElementsByName("v1");
 var radio2 = document.getElementsByName("v2");
 var radio3 = document.getElementsByName("v3");


   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;
  }


   
     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;
  }
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;

 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;
  }
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;
 break;
     }
   }







      drawChart();
      }

      function drawChart() {
     
       var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work',     n1],
          ['Eat',      n2],
          ['Commute',  n3],
         ['an',  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>


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

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

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


 <input type="button" value="submit" onclick="add()"/>
 <input type="button" value="random" onclick="Random()"/>
    <div id="piechart" style="width: 900px; height: 500px;"></div>

  </body>
</html>

5/13

5/13

<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 add() {
            var a ;
            var b ;
            alert('result value');
}

                 function drawChart() {

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

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

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

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="piechart" style="width: 900px; height: 500px;"></div>
    <input type="button" value="submit" onclick="add()"/>
  </body>
</html>