我有这个 HTML 代码
<html>
<head>
<script type="text/javascript">
window.onload = function(){
document.getElementById("shipping-method").onchange = function(){
window.scrollTo(0, 0);
};
};
</script>
<script>
function calc() {
var subtotal = parseFloat(document.getElementById("subtotal").innerHTML.substring(1));
var shipping = parseInt(document.getElementById("shipping-method").value);
if(shipping == 1) {
var total = subtotal+6.95;
document.getElementById("shipping").innerHTML = "$"+6.95;
} else {
var total = subtotal+17.95;
document.getElementById("shipping").innerHTML = "$"+17.95;
}
document.getElementById("total").innerHTML = "$"+total;
}
</script>
</head>
<body>
<select onchange="calc()" class="shipping-method" id="shipping-method">
<option value="">-Choose a shipping method-</option>
<option selected="selected" value="1">normal shipping - $6.95</option>
<option value="2">Priority Shipping - $17.95</option>
</select>
<div class="calculations">
<table>
<tbody><tr>
<td>Subtotal:</td>
<td id="subtotal">$97.00</td>
</tr>
<tr>
<td>Shipping:</td>
<td id="shipping">$6.95</td>
</tr>
<tr class="total">
<td>Total:</td>
<td id="total">$103.95</td>
</tr>
</tbody></table>
</div>
</body>
</html>
下拉菜单位于网页的底部,所以我使用第一个脚本在选择一个选项并获得总数后让用户到达页面顶部,但是两个脚本不能一起工作,我有删除其中一个以使另一个工作,如何使两个脚本一起工作而没有任何冲突,谢谢。