台北市的...
請參考...
語法:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-tw">
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>價格加總</title>
</head>
<body>
<p><br>
</p>
<table border="1" width="600" id="table1">
<tr>
<td colspan="4">使用級數:<select id="UserType_ddl" size="1" onchange="CountALL();">
<option value="0">甲級</option>
<option value="1">乙級</option>
<option value="2">丙級</option>
<option value="3">丁級</option>
</select>
日期類別:<select id="DateType_ddl" size="1" onchange="CountALL();">
<option value="0">平日</option>
<option value="1">減價日</option>
<option value="2">加價日</option>
</select><p> </td>
</tr>
<tr>
<td>項目類別</td>
<td>說明</td>
<td>數量</td>
<td>小計</td>
</tr>
<tr>
<td>禮堂使用費</td>
<td>
依甲乙丙丁級區分,依平日或加價減價日分
</td>
<td><input id="PlaceUse_Amount" type="text" onkeyup="CountALL();" value="1" size="5">小時</td>
<td><span id="PlaceUse_price">0</span></td>
</tr>
<tr>
<td>禮堂冷氣費</td>
<td>
依甲乙丙丁級區分</td>
<td><input id="PlaceCold_Amount" type="text" onkeyup="CountALL();" value="1" size="5">小時</td>
<td><span id="PlaceCold_price">0</span></td>
</tr>
<tr>
<td>禮堂善後處理費</td>
<td>
依甲乙丙丁級區分</td>
<td>
<input id="PlaceAfter_Amount" type="text" onkeyup="CountALL()" value="1" size="5">次</td>
<td><span id="PlaceAfter_price">0</span></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="4"> <p><br>
以下資料設籍外縣市者3倍:<select id="LiveCity_ddl" onchange="CountALL();" size="1">
<option value="1">設籍本市</option>
<option value="3">設籍外縣市</option>
</select></td>
</tr>
<tr>
<td>項目類別</td>
<td>說明</td>
<td>數量</td>
<td>小計</td>
</tr>
<tr>
<td>火葬費</td>
<td>設籍本市者2,000</td>
<td>
<input id="D3_Amount0" type="text" onkeyup="CountALL();" value="1" size="5" name="T1">具</td>
<td><span id="D3_price0">0</span></td>
</tr>
<tr>
<td>骨灰罐寄存</td>
<td>設籍本市者10,000元</td>
<td>
<input id="D3_Amount1" type="text" onkeyup="CountALL();" value="1" size="5" name="T2">個</td>
<td><span id="D3_price1">0</span></td>
</tr>
<tr>
<td>檢骨罈寄存</td>
<td>設籍本市者30,000元</td>
<td>
<input id="D3_Amount2" type="text" onkeyup="CountALL();" value="1" size="5" name="T3">個</td>
<td><span id="D3_price2">0</span></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>總計</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><span id="total_price">0</span></td>
</tr>
</table>
<script>
var PlacePrice = new Array(); //禮堂使用費
PlacePrice[0] = new Array("1800","600","3600"); //甲級使用費 : 平日,減價日,加價日
PlacePrice[1] = new Array("750","300","1500"); //乙級使用費 : 平日,減價日,加價日
PlacePrice[2] = new Array("600","225","1200"); //丙級使用費 : 平日,減價日,加價日
PlacePrice[3] = new Array("225","75","450"); //丁級使用費 : 平日,減價日,加價日
var ColdPrice = new Array("1200","450","300","150"); //冷氣使用費,甲乙丙丁4級
var AfterOperationPrice = new Array("500","300","200","100"); //禮堂善後處理費 甲級500元,乙級300元,丙級200元,丁級100元
//所有的單價的標籤id...要用分號區隔
var priceID = "PlaceUse_price;PlaceCold_price;PlaceAfter_price;D3_price0;D3_price1;D3_price2";
function CountALL() //計算總金額...
{
//禮堂使用費
document.getElementById("PlaceUse_price").innerHTML = PlacePrice[document.getElementById("UserType_ddl").value][document.getElementById("DateType_ddl").value] * document.getElementById("PlaceUse_Amount").value;
//禮堂冷氣費
document.getElementById("PlaceCold_price").innerHTML = ColdPrice[document.getElementById("UserType_ddl").value] * document.getElementById("PlaceCold_Amount").value;
//禮堂善後處理
document.getElementById("PlaceAfter_price").innerHTML = ColdPrice[document.getElementById("UserType_ddl").value] * document.getElementById("PlaceAfter_Amount").value;
//火葬費
document.getElementById("D3_price0").innerHTML = document.getElementById("LiveCity_ddl").value * 2000 * document.getElementById("D3_Amount0").value;
//骨灰罐寄存
document.getElementById("D3_price1").innerHTML = document.getElementById("LiveCity_ddl").value * 10000 * document.getElementById("D3_Amount1").value;
//檢骨罈寄存
document.getElementById("D3_price2").innerHTML = document.getElementById("LiveCity_ddl").value * 30000 * document.getElementById("D3_Amount2").value;
//將所有的單價標籤, 轉成陣列, 以便加總金額
var myPriceArray = priceID.split(";");
var myCount = 0;
for (var i=0;i< myPriceArray.length;i++)
{
if(document.getElementById(myPriceArray[i]))
{
myCount = myCount + (document.getElementById(myPriceArray[i]).innerHTML * 1);
}
else
{
alert("找不到價格標籤的ID : " + myPriceArray[i]);
return false;
}
}
document.getElementById("total_price").innerHTML = myCount;
}
//執行一次總計算...
CountALL();
</script>
</body>
</html>