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 ;
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");
var radio5=document.getElementsByName("v5");
var radio6=document.getElementsByName("v6");
var radio7=document.getElementsByName("v7");
var radio8=document.getElementsByName("v8");
var radio9=document.getElementsByName("v9");
var radio10=document.getElementsByName("v10");
for(var i=0;i<radio1.length;i++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
v1= i;
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++){
radio2.item(i)==true
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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<radio5.length;i++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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<radio6.length;i++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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<radio7.length;i++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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<radio8.length;i++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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<radio9.length;i++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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<radio10.length;i++){
var maxNum = 3;
var minNum = 1;
var i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
i = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
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'],
['同意', a],
['不同意', b],
['沒意見', c],
]);
var options = {
title: 'My Daily Activities'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<h1>1、ssss?</h1>
<input name="v1" type="radio" value="1.1">同意
<input name="v1" type="radio" value="1.2">不同意
<input name="v1" type="radio" value="1.3">沒意見
<br>
<h1>2、ssss?</h1>
<input name="v2" type="radio" value="1.1">同意
<input name="v2" type="radio" value="1.2">不同意
<input name="v2" type="radio" value="1.3">沒意見
<br>
<h1>3、ssss?</h1>
<input name="v3" type="radio" value="1.1">同意
<input name="v3" type="radio" value="1.2">不同意
<input name="v3" type="radio" value="1.3">沒意見
<br>
<h1>4、ssss?</h1>
<input name="v4" type="radio" value="1.1">同意
<input name="v4" type="radio" value="1.2">不同意
<input name="v4" type="radio" value="1.3">沒意見
<br>
<h1>5、ssss?</h1>
<input name="v5" type="radio" value="1.1">同意
<input name="v5" type="radio" value="1.2">不同意
<input name="v5" type="radio" value="1.3">沒意見
<br>
<h1>6、ssss?</h1>
<input name="v6" type="radio" value="1.1">同意
<input name="v6" type="radio" value="1.2">不同意
<input name="v6" type="radio" value="1.3">沒意見
<br>
<h1>7、ssss?</h1>
<input name="v7" type="radio" value="1.1">同意
<input name="v7" type="radio" value="1.2">不同意
<input name="v7" type="radio" value="1.3">沒意見
<br>
<h1>8、ssss?</h1>
<input name="v8" type="radio" value="1.1">同意
<input name="v8" type="radio" value="1.2">不同意
<input name="v8" type="radio" value="1.3">沒意見
<br>
<h1>9、ssss?</h1>
<input name="v9" type="radio" value="1.1">同意
<input name="v9" type="radio" value="1.2">不同意
<input name="v9" type="radio" value="1.3">沒意見
<br>
<h1>10、ssss?</h1>
<input name="v10" type="radio" value="1.1">同意
<input name="v10" type="radio" value="1.2">不同意
<input name="v10" type="radio" value="1.3">沒意見
<br>
同意:
<input type="text" name="FirstName" id="c1"<br><br/>
不同意:
<input type="text" name="address" id="c2"<br><br/>
沒意見:
<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>
留言列表