无意中翻出多年前在广东写的三人分房租水电的脚本。那时房租好便宜呀。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>房租水电计算及分配</title>
<script language="javascript">
function calcwater(){
var water1 = document.form1.txt1.value;
var water2 = document.form1.txt2.value;
var water3 = document.form1.txt3.value;
document.form1.txt4.value=(water2-water1)*water3;
document.form1.txt15.value=(water2-water1);
}
function calcpower(){
var water5 = document.form1.txt5.value;
var water6 = document.form1.txt6.value;
var water7 = document.form1.txt7.value;
document.form1.txt8.value=(water6-water5)*water7;
document.form1.txt16.value=(water6-water5);
document.form1.txt13.value = 800+(parseFloat(document.form1.txt4.value) + parseFloat(document.form1.txt8.value));
}
function calc(){
var x = (parseFloat(document.form1.txt4.value) + parseFloat(document.form1.txt8.value))/3;
document.form1.txt10.value = 280+parseFloat(x);
document.form1.txt11.value = 280+parseFloat(x);
document.form1.txt12.value = 240+parseFloat(x);
}
</script>
<style type="text/css">
input{
width:75px;
}
</style>
</head>
<body>
<form name="form1" method="post" action="">
<table width="850" height="207" border="1" align="center" cellpadding="5" cellspacing="0">
<tr align="center" valign="middle">
<td colspan="8"><div align="center">房租水电计算及分配</div></td>
</tr>
<tr align="center" valign="middle">
<td >上次水表</td>
<td width="77" ><input name="txt1" type="text" id="txt1"></td>
<td >本次水表</td>
<td ><input name="txt2" type="text" id="txt2"></td>
<td ><input name="txt15" type="text" id="txt15" readonly>
吨</td>
<td ><input name="txt3" type="text" id="txt3" value="2.4" readonly="">
元/吨</td>
<td ><div align="center">
<input type="button" name="Submit" value="计算水费" onClick="calcwater()">
</div></td>
<td ><input name="txt4" type="text" id="txt4"></td>
</tr>
<tr align="center" valign="middle">
<td>上次电表</td>
<td><input name="txt5" type="text" id="txt5"></td>
<td>本次电表</td>
<td><input name="txt6" type="text" id="txt6"></td>
<td><input name="txt16" type="text" id="txt16">
度</td>
<td><input name="txt7" type="text" id="txt7" value="0.64" readonly="">
元/度</td>
<td><div align="center">
<input type="button" name="Submit" value="计算电费" onClick="calcpower()">
</div></td>
<td><input name="txt8" type="text" id="txt8"></td>
</tr>
<tr align="center" valign="middle">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>本月应付房租+水电</td>
<td><input name="txt13" type="text" id="txt13"></td>
</tr>
<tr align="center" valign="middle">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><div align="center">
<input type="button" name="Submit" value="本月分配" onClick="calc()">
</div></td>
<td> </td>
</tr>
<tr align="center" valign="middle">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><div align="center">汤</div></td>
<td><input name="txt10" type="text" id="txt10"></td>
</tr>
<tr align="center" valign="middle">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><div align="center">冯</div></td>
<td><input name="txt11" type="text" id="txt11"></td>
</tr>
<tr align="center" valign="middle">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td><div align="center">雯</div></td>
<td><input name="txt12" type="text" id="txt12"></td>
</tr>
</table>
</form>
</body>
</html>