日期:2014-05-17 浏览次数:20387 次
<html>
<script language="javascript">
function calc(){
var sum =document.getElementById("textbox1").value;
var count=document.getElementById("textbox2").value;
var avg = sum/count;
document.getElementById("textbox3").value=parseInt(avg);
}
</script>
<body>
总消费:<input type="text" id="textbox1" onblur="calc()"/><br/>
总人数:<input type="text" id="textbox2" onblur="calc()"/><br/>
人均消费:<input type="text" id="textbox3"/>
</body>
</html>
<html>
<script language="javascript">
function calc(){
var sum =document.getElementById("textbox1").value;
var count=document.getElementById("textbox2").value;
if(sum=="")
{
return false;
}
if(count=="")
{
return false;
}
var avg = sum/count;
document.getElementById("textbox3").value=parseInt(avg);
return true;
}
</script>
<body>
总消费:<input type="text" id="textbox1" onmouseout="calc()"/><br/>
总人数:<input type="text" id="textbox2" onmouseout="calc()"/><br/>
人均消费:<input type="text" id="textbox3"/>
</body>
</html>
<html>
<script language="javascript">
function calc(){
var sum =document.getElementById("<%= textbox1.ClientID %>").value;
var count=document.getElementById("<%= textbox2.ClientID %>").value;
if(sum=="")
{
return false;
}
if(count=="")
{
return false;
}
var avg = sum/count;
document.getElementById("<%= textbox3.ClientID %>").value=parseInt(avg);
return true;
}
</script>
<body>
总消费:<asp:TextBox type="text" runat="server" id="textbox1" onmouseout="calc()"/><br/>
总人数:<asp:TextBox type="text" runat="server" id="textbox2" onmouseout="calc()"/><br/>
人均消费:<asp:TextBox type="text" runat="server" id="textbox3"/>
</body>
</html>