<!DOCTYPE html ><html >
<head>
<title>
Form
</title>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script>
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
var a;
var b;
var c;
function check1() {
a=0;
b=0;
c=0;
var radio1=document.getElementsByName("v1");
var radio2=document.getElementsByName("v2");
var radio3=document.getElementsByName("v3");
var flag=new Array();
for(var i=0;i<radio1.length;i++){
if(radio1.item(i).checked==true) {
flag[1]=i+1;
alert(flag[1]);
break;
}
}
for(var i=0;i<radio2.length;i++){
if(radio2.item(i).checked==true) {
flag[2]=i+1;
alert(flag[2]);
break;
}
}
for(var i=0;i<radio3.length;i++){
if(radio3.item(i).checked==true) {
flag[3]=i+1;
alert(flag[3]);
break;
}
}
for(var i=1;i<11;i++)
{
if(flag[i]==1)
{a=a+1;}
document.getElementById('c1').value=a;
}
for(var i=1;i<11;i++)
{
if(flag[i]==2)
{b=b+1;}
document.getElementById('c2').value=b;
}
for(var i=1;i<11;i++)
{
if(flag[i]==3)
{c=c+1;}
document.getElementById('c3').value=c;
}
drawChart()
}
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['1', a],
['2', b],
['3', c]
]);
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、ssss?</h1>
<input name="v1" type="radio" value="1">1
<input name="v1" type="radio" value="2">2
<input name="v1" type="radio" value="3">3
<h1>2、ssss?</h1>
<input name="v2" type="radio" value="1">1
<input name="v2" type="radio" value="2">2
<input name="v2" type="radio" value="3">3
<h1>3、ssss?</h1>
<input name="v3" type="radio" value="1">1
<input name="v3" type="radio" value="2">2
<input name="v3" type="radio" value="3">3
</form>
c1:
<input type="text" name="submit" id="c1" /><br><br/>
c2:
<input type="text" name="submit" id="c2" /><br><br/>
c3:
<input type="text" name="submit" id="c3" /><br><br/>
<input type="button" value="submit" onclick="check1()"/>
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>
沒有留言:
張貼留言