function setSelectedValue(parUM)//设置dorpdownlist的选定值
{
var ddlVUM='<%=FormView1.FindControl("DropDownList2").ClientID%>';
var i=document.all(ddlVUM).options.length;
var j;
for(j=0;j<i;j++)
{
if(document.all(ddlVUM).options[j].text==parUM)
document.all(ddlVUM).selectedIndex=j
}
}
function Measurement()
{
var txtLength= '<%=FormView1.FindControl("lengthTextBox").ClientID%>';
var txtWidth= '<%=FormView1.FindControl("widthTextBox").ClientID%>';
var txtHeight= '<%=FormView1.FindControl("heightTextBox").ClientID%>';
var txtVolume= '<%=FormView1.FindControl("volumeTextBox").ClientID%>';
var ddlUM='<%=FormView1.FindControl("DropDownList1").ClientID%>';
var ddlVUM='<%=FormView1.FindControl("DropDownList2").ClientID%>';
var Length=document.getElementById(txtLength).value;
if(Length=='') Length=0;
var Width=document.getElementById(txtWidth).value;
if(Width=='') Width=0;
var Height=document.getElementById(txtHeight).value;
if(Height=='') Height=0;
//var UM= document.all(ddlUM).selectedIndex;
var UM=document.all(ddlUM).options[document.all(ddlUM).selectedIndex].text;
var VUM=document.getElementById(ddlVUM).innerText;
var Volume;
switch(UM)
{
case "M":
Volume=Length*Width*Height;
document.getElementById(txtVolume).innerText=Volume;
setSelectedValue('CBM');
break;
case "CM":
Volume=(Length/100)*(Width/100)*(Height/100);
document.getElementById(txtVolume).innerText=Volume;
setSelectedValue('CBM');
break;
case "IN":
Volume=(Length/12)*(Width/12)*(Height/12);
document.getElementById(txtVolume).innerText=Volume;
setSelectedValue('CBFT');
break;
case "FT":
Volume=Length*Width*Height;
Volume=(Length/12)*(Width/12)*(Height/12);
document.getElementById(txtVolume).innerText=Volume;
setSelectedValue('CBFT');
default:
{
Volume=Length*Width*Height;
document.getElementById(txtVolume).innerText=Volume;
setSelectedValue('CBM');
}
}
}