0

我正在尝试根据提供的值计算表格,我已经编写了脚本,但它说缺少;声明之前

这是我的代码,如果有人可以看到错误,请帮助指出。

   <script type="text/javascript">
       function calc(theForm) {
       var myEquip1 = document.Edit.EQup1.value;
       var myEquip2 = document.Edit.EQup2.value;
       Var myFixedPrice = document.Edit.InitialPrice.value;
       Var myEquip1Price = document.Edit.EQup1Price.value;
       Var myEquip2Price = document.Edit.EQup2Price.value;

     if  (myEquip1 > 1)
     {
    var myEquip1Total = (myEquip1*myEquip1Price) - (myEquip1Price);
     }
else
 {
    var myEquip1Total = (myEquip1*myEquip1Price)-(myEquip1Price);
      }
     if  (myEquip2 > 1)
      {
    var myEquip2Total = (myEquip2*myEquip2Price)-(myEquip2Price);
      }
else
      {
    var myEquip2Total = (myEquip2*myEquip2Price)-(myEquip2Price);
}
    theForm.GrandTotal.value = (myEquip2Total+myEquip1Total+myFixedPrice)
    }
    </script>

HTML 在下面我确定我做错了什么,但我可以看到它。

    <form name="Edit" method="post" action="mypageprocess">
<p><label for="EQup1">How many Branches?</label><br />
<select name="EQup1" onChange="calc(this.form)" id="EQup1"/>    
        <option value="0">Please select</option> 
        <option value="1" >One</option>
        <option value="2" >Two</option>
        <option value="3" >Three</option>
        <option value="4" >Four</option>
        <option value="5" >Five</option>
        </select> &nbsp;&nbsp; x <strong>$550.00</strong>
</p> 
<p><label for="EQup2">How many Satellits?</label><br />
<select name="EQup2" onChange="calc(this.form)" id="EQup2"/>    
        <option value="0">Please select</option> 
        <option value="1" >One</option>
        <option value="2" >Two</option>
        <option value="3" >Three</option>
        <option value="4" >Four</option>
        <option value="5" >Five</option>
        </select> &nbsp;&nbsp; x <strong>$440.00 </strong>
</p> 

<input type="text" onfocus="this.blur();" name="GrandTotal" size="10" readonly="readonly"/>
        <input type="hidden" name="InitialPrice" value="660" />
        <input type="hidden" name="EQup1Price" value="550" />
        <input type="hidden" name="EQup2Price" value="440" />
    </form>

谢谢

4

2 回答 2

5

JavaScript 区分大小写。Var行不通,var

于 2012-06-06T22:17:02.493 回答
2

您的两个<select>元素都被过早关闭,就好像它们没有内部内容一样。

于 2012-06-06T22:22:16.963 回答