using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;public partial class pollresutl : System.Web.UI.Page { public int nBar0Len = 0;//对应“会”项图片的长度 public int nBar1Len = 0;//对应“不会”项图片的长度 public int nBar2Len = 0;//对应“不知道”项图片的长度 public float poll0Ratio = 0F;//对应“会”项百分比 public float poll1Ratio = 0F;//对应“不会”项百分比 public float poll2Ratio = 0F;//对应“不知道”项百分比 public int nSum = 0;//总投票数 //初始化投票数,实际开发时可以从数据库或者文件中获取投票数 int[] nPollArr = new int[] {12,45,67 }; protected void Page_Load(object sender, System.EventArgs e) { //读取resutl字段的值,并且对应项的票数加1 int n = int.Parse(Request.QueryString["result"].ToString()); if (n >= 0) nPollArr[n] ++; //计算票的总数 nSum = sumArr(nPollArr); //计算第一项票数的百分比 poll0Ratio = Convert.ToSingle((float)nPollArr[0]/nSum); poll1Ratio = Convert.ToSingle((float)nPollArr[1]/nSum); poll2Ratio = Convert.ToSingle((float)nPollArr[2]/nSum); //计算每一项对应的图像的宽度 nBar0Len = Convert.ToInt32(poll0Ratio*500); nBar1Len = Convert.ToInt32(poll1Ratio*500); nBar2Len = Convert.ToInt32(poll2Ratio*500); //设置每一项对应图片的宽度 Image1.Width = nBar0Len; Image2.Width = nBar1Len; Image3.Width = nBar2Len; //将百分比显示在标签中 lblCan.Text = poll0Ratio.ToString(); lblCanNot.Text = poll1Ratio.ToString(); lblUnKnow.Text = poll2Ratio.ToString(); //将总数显示在标签中 lblAll.Text = nSum.ToString(); } private int sumArr(int[] arr) { int sum = 0; for (int i = 0; i < arr.Length; i++) sum += arr[i]; return sum; } }
http://download.csdn.net/source/809917
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class pollresutl : System.Web.UI.Page
{
public int nBar0Len = 0;//对应“会”项图片的长度
public int nBar1Len = 0;//对应“不会”项图片的长度
public int nBar2Len = 0;//对应“不知道”项图片的长度
public float poll0Ratio = 0F;//对应“会”项百分比
public float poll1Ratio = 0F;//对应“不会”项百分比
public float poll2Ratio = 0F;//对应“不知道”项百分比
public int nSum = 0;//总投票数
//初始化投票数,实际开发时可以从数据库或者文件中获取投票数
int[] nPollArr = new int[] {12,45,67 };
protected void Page_Load(object sender, System.EventArgs e)
{
//读取resutl字段的值,并且对应项的票数加1
int n = int.Parse(Request.QueryString["result"].ToString());
if (n >= 0)
nPollArr[n] ++;
//计算票的总数
nSum = sumArr(nPollArr);
//计算第一项票数的百分比
poll0Ratio = Convert.ToSingle((float)nPollArr[0]/nSum);
poll1Ratio = Convert.ToSingle((float)nPollArr[1]/nSum);
poll2Ratio = Convert.ToSingle((float)nPollArr[2]/nSum);
//计算每一项对应的图像的宽度
nBar0Len = Convert.ToInt32(poll0Ratio*500);
nBar1Len = Convert.ToInt32(poll1Ratio*500);
nBar2Len = Convert.ToInt32(poll2Ratio*500);
//设置每一项对应图片的宽度
Image1.Width = nBar0Len;
Image2.Width = nBar1Len;
Image3.Width = nBar2Len;
//将百分比显示在标签中
lblCan.Text = poll0Ratio.ToString();
lblCanNot.Text = poll1Ratio.ToString();
lblUnKnow.Text = poll2Ratio.ToString();
//将总数显示在标签中
lblAll.Text = nSum.ToString();
}
private int sumArr(int[] arr)
{
int sum = 0;
for (int i = 0; i < arr.Length; i++)
sum += arr[i];
return sum;
}
}
可以提供添加一项,点击多选 显示一个最多选择多少个的下拉框吗?效果在QQ校友和QQ空间都有
我下载他们的JS 汉字都是乱码 而且有三个JS页面 没有必要