簡體   English   中英

“其他”在javascript函數中不起作用

[英]“else” doesn't work in javascript function

我對javascript很陌生,但是我想做一個復選框,將Billto信息復制到shipto框中。 我有一個帶有onclick事件的復選框,設置如下:

<input type="checkbox" name="chkSame" id="chkSame" onClick="fncCheckbox()"/> same as customer info<br/>

我在以下函數的其他行上收到“ Expected';'”錯誤。 如果我完全取出IF語句,它將起作用。 如果我只是放棄ELSE,或者如果我將ELSE保留為1行並擺脫了{}括號,它將起作用。 當我在測試頁上設置非常相似的內容時,它會起作用。 我不知道為什么在這種情況下不起作用。 該功能如下:

<script type="text/javascript">
  function fncCheckbox()
    {
 if (document.RepairRequestform.chkSame.checked) {
          document.RepairRequestform.txtShipName.value =   document.RepairRequestform.txtBillName.value;
          document.RepairRequestform.txtShipCompany.value = document.RepairRequestform.txtBillCompany.value;
   document.RepairRequestform.txtShipAddress.value = document.RepairRequestform.txtBillAddress.value;
   document.RepairRequestform.txtShipAddress2.value = document.RepairRequestform.txtBillAddress2.value;
   document.RepairRequestform.txtShipCity.value = document.RepairRequestform.txtBillCity.value;
   document.RepairRequestform.txtShipState.value = document.RepairRequestform.txtBillState.value;
   document.RepairRequestform.txtShipZip.value = document.RepairRequestform.txtBillZip.value;
    } Else {
   document.RepairRequestform.txtShipName.value = "";
   document.RepairRequestform.txtShipCompany.value = "";
   document.RepairRequestform.txtShipAddress.value = "";
   document.RepairRequestform.txtShipAddress2.value = "";
   document.RepairRequestform.txtShipCity.value = "";
   document.RepairRequestform.txtShipState.value = "";
   document.RepairRequestform.txtShipZip.value = "";
 }
   }
 </script>

否則應該全部小寫,JavaScript區分大小寫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM