Custom Java Script - perform calculation depending on Checkbox value
Hello,
I have a form that a user will select if a specific item is for a member or non member (with associated price discount for members). They also have to enter a Quantity. There is then a total amount field that gets automatically calculated. I have part of this working but would like the Total amount field to go back to being null if the user unchecks the Quantity and Member or Nonmember checkbox. Here is the code that I currently have:
if (this.getField("511 Digital Access Code Ckbx").valueAsString == "No") event.value=(this.getField("511 Digital Access Code Qty").value * 40);
if (this.getField("511 Digital Access Code Ckbx").valueAsString == "Yes") event.value=(this.getField("511 Digital Access Code Qty").value * 20);
if (this.getField("511 Digital Access Code Qty").value == null) event.value=(this.getField("511 Digital Access Code Total").value == null);
if (this.getField("511 Digital Access Code Qty").rawValue.length == 0) event.value=(this.getField("511 Digital Access Code Total").value == null);
example of issue. User selects member pricing ($20) for an item with the Quanity of 5 . The Total field calculates to $100. That all works fine. If they unselect the checkbox and clear out the Quantity field, I still have a total of $100 in the Total field.
