views:

52

answers:

1

I'm very new to javascript but I'm trying to make a checkbox that will copy the billto information into the shipto boxes. I have the checkbox with an onclick event, set up like so:

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

I get an error of "Expected ';'" on the Else line in the following function, though. It works if I take out the IF statement altogether. It works if I just get rid of the ELSE or if I leave the ELSE as 1 line and get rid of the { } brackets. It works when I set up something very similar on a test page. I have no idea why it doesn't work in this case though. The function is below:

<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>
+11  A: 

else is supposed to be all lower case, JavaScript is case sensitive.

Zachary
ah, I'm too slow...+1
kekekela