<html>
<head>
<title>二氧化碳计算器</title>
<style type="text/css">
#blue{
color:#0080FF;
font:"宋体";
font-size:12px;
width:17%;
height:30
}
#red{
color:#EE3304;
font:"宋体";
font-size:12px;
width:17%;
height:30
}
</style>
</head>
<body onload="focus2()"><!-- 让光标出现在第一行上 -->
<br>
<div align="center" class="title-font"><h1>二氧化碳排放量计算器</h1><h3>印染行业</h3></div>
<div align="center" class="title-font">【本计算器可以计算您企业每天二氧化碳排放量,注意时间单位是/天】</div><br>
<table align="center" border="3" bgcolor="#CCCCCC" style="border-left-width:3px; border-left-color:#CCCCCC;
border-bottom-width:1px; border-bottom-color:#CCCCCC">
<tr>
<td><div align="center"><a href="mianfang.htm" >棉纺行业</a></div><br>
<div align="center"><a href="huaxian.htm" >化纤行业</a></div><br>
<div align="center"><a href="yinran.htm" >印染行业</a></div><br>
<div align="center"><a href="fuzhuang.htm" >服装行业</a></div>
</td>
<td colspan="2">
直接能耗用电量:
<input type="text" name="text0" onfocus="focus1(this);" size="23" style="height=25; font-size:16px; text-align:right">度<br>
<!-- //onfocus:当输入获得焦点后,产生该文件 -->
公用办公用电量:
<input type="text" name="text1" onfocus="focus1(this);" size="23" style="height=25; font-size:16px; text-align:right">度<br>
直接能耗用水量:
<input type="text" name="text2" onfocus="focus1(this);" size="23" style="height=25; font-size:16px; text-align:right">吨<br>
公用办公用水量:
<input type="text" name="text3" onfocus="focus1(this);" size="23" style="height=25; font-size:16px; text-align:right">吨<br>
总用汽量:
<input type="text" name="text4" onfocus="focus1(this);" size="23" style="height=25; font-size:16px; text-align:right">吨<br>
<br>
二氧化碳排放量:
<input type="text" name="text5" onfocus="focus1(this);" size="23" style="height=25; font-size:16px; text-align:right" readonly="true">吨
</td>
</tr>
<tr>
<td></td>
<td align="center">
<input type="button" name="C" value="重 置" style="width:20%" id="red" onClick="reset()">
<input type="button" name="backspace" value="退 格" style="width:20%" id="red" onClick="backspace()">
</td>
</tr>
<tr>
<td></td>
<td align="center">
<input type="button" name="button7" value="7" id="blue" onClick="display(7)">
<input type="button" name="button8" value="8" id="blue" onClick="display(8)">
<input type="button" name="button9" value="9" id="blue" onClick="display(9)">
</td>
</tr>
<tr>
<td></td>
<td align="center">
<input type="button" name="button4" value="4" id="blue" onClick="display(4)">
<input type="button" name="button5" value="5" id="blue" onClick="display(5)">
<input type="button" name="button6" value="6" id="blue" onClick="display(6)">
</td>
</tr>
<tr>
<td></td>
<td align="center">
<input type="button" name="button1" value="1" id="blue" onClick="display(1)">
<input type="button" name="button2" value="2" id="blue" onClick="display(2)">
<input type="button" name="button3" value="3" id="blue" onClick="display(3)">
</td>
</tr>
<tr>
<td></td>
<td align="center">
<input type="button" name="decimal" value="." id="red" onClick="display('.')">
<input type="button" name="button0" value="0" id="blue" onClick="display(0)">
<input type="button" name="decimal" value="再算一次" id="red" onClick="os()">
<form><input type="button" name="calculate" value="计 算" id="red" onClick="compute()"></form>
</td>
</tr>
</table>
</body>
<script language="JavaScript">
function focus1(temp)
{
text = temp;
}
function focus2()
{
document.getElementsByName("text0")[0].focus();
}
function compute(){
var u,v,w,x,y,z;
u=parseInt(text0.value);
v=parseInt(text1.value);
w=parseInt(text2.value);
x=parseInt(text3.value);
y=parseInt(text4.value);
z=((u+v)*0.1229/1000+(w+x)*0.2429/1000+y/5*0.7143)*2.41;
text5.value=Math.round(z*100000)/100000;
}
var interim;
var sign = 0;
var clearSign = 0;
var text ;
//再算一次
function os() {
window.document.forms[0].action="yinran.htm"
window.document.forms[0].submit();
}
//此方法用来处理数字、“.”、“+/-”等按钮输入
function display(x){
if(clearSign == 0){
text.value = "";
clearSign = 1;
}
if(x == "."){
if(text.value.indexOf(".")==-1){
text.value = text.value+".";
}
if(text.value.indexOf(".")==0){
text.value = 0 + text.value;
}
}
else{
if(text.value.indexOf(".")!=-1)
{
text.value = text.value+x;
}
else{
text.value = parseFloat(text.value+x);
}
}
}
//退格
function backspace(){
text.value = text.value.substring(0,text.value.length-1);
}
//重置方法
function reset(){
interim = "";
text.value = "";
sign = 0;
}
</script>
</html>