Question
How to set form field to auto fill based on another field
- I have fields that are autopopulated based on radio button selection of another field (point values 0-5 or fewer options for some).
- I then have a field (named TotalPoints) that sums these values, minimum total points=1, maximum=23 (integers)
- My third field (named Accreditation Fee) needs to display a price (or simply a number) based on the total points.
- If the points > than 15, I created a field (named ContactOCPD) with the folloing JavaScript (located in custom caluculation script) that works perfectly:
var t = this.getField("TotalPoints").value;
if (t > 15) {event.value = "Contact OCPD";}
else {event.value = "";}
- I created another field (which will sit on top of field from 4) with the folloing JavaScript. Nothing happens:
var t = this.getField("TotalPoints").value;
if (t = 0) {event.value = 0;}
else if (t > 0 && t < 4) {event.value = 500;}
else if (t > 3 && t < 7) {event.value = 1000;}
else if (t > 6 && t < 9) {event.value = 2000;}
else if (t > 8 && t < 12) {event.value = 3000;}
else if (t > 11 && t < 14) {event.value = 4000;}
else if (t > 13 && t <16) {event.value = 5000;}
else if (t>15) {event.value = "";}
What am I doing wrong? I have tried playing with the brackets and quotations. Nothing shows up in the field, no matter what number is in the TotalPoints field. Thank you!
