Copy link to clipboard
Copied
FIELD NAME: TOTAL, LINE2, LINE3, CHECKBOX1 YES, CHECKBOX1 NO.
please i need a script where if TOTAL is more than 600, CHECKBOX1 YES will be clicked and substract 600 from TOTAL
and enter the result in LINE2.
If no CHECKBOX1 NO will be clicked and enter 0 in LINE3.
Note: the check boxes are part of the same group
Thanks!!!!!
Copy link to clipboard
Copied
Checkboxes are checked automaticaly depending of value in total?
Copy link to clipboard
Copied
Yes
Copy link to clipboard
Copied
FIELD NAME: TOTAL, LINE2, LINE3, CHECKBOX1 YES, CHECKBOX1 NO.
please i need a script where if TOTAL is more than 600, CHECKBOX1 YES will checked automaticaly and substract 600 from TOTAL
and enter the result in LINE2.
If no, CHECKBOX1 NO will checked automaticaly and enter 0 in LINE3.
Notes: the check boxes are part of the same group
Thanks!!!!!
Copy link to clipboard
Copied
You can use this script in TOTAL field:
if(event.value > 600){
this.getField("CHECKBOX1").value = "YES";
this.getField("LINE2").value = event.value-600;}
else if(event.value <= 600){
this.getField("CHECKBOX1").value = "NO";
this.getField("LINE3").value = 0;}
Copy link to clipboard
Copied
I want to add the script in a hidden new field instead.
How can i do that please?
Copy link to clipboard
Copied
Just replace 'event.value' with:
this.getField("TOTAL").value
Copy link to clipboard
Copied
Ok i will try my best thank you very much!!!
Copy link to clipboard
Copied
It works!!!! But the issue now when TOTAL is blank or when resetting the form, the CHECKBOX1 NO is still being checked and LINE3 is still says 0
To eliminate that i add this script at the end:
else if(this.getField("TOTAL").value = "";){
this.getField("CHECKBOX1").value = "";
this.getField("LINE3").value = "";}
But I got error!!! What did i do wrong please?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
if(this.getField("TOTAL").value > 600){
this.getField("CHECKBOX1").value = "YES";
this.getField("LINE2").value = event.value-600;}
else if(event.value <= 600){
this.getField("CHECKBOX1").value = "NO";
this.getField("LINE3").value = 0;}
else if(this.getField("TOTAL").value = ""{
this.getField("CHECKBOX1").value = "";
this.getField("LINE3").value = "";}
Copy link to clipboard
Copied
Syntax Error: missing ) after condition 7: at line 8
Copy link to clipboard
Copied
if(this.getField("TOTAL").value > 600){
this.getField("CHECKBOX1").value = "YES";
this.getField("LINE2").value = event.value-600;}
else if(event.value <= 600){
this.getField("CHECKBOX1").value = "NO";
this.getField("LINE3").value = 0;}
else if(this.getField("TOTAL").value = ""){
this.getField("CHECKBOX1").value = "";
this.getField("LINE3").value = "";}
Copy link to clipboard
Copied
Ok i got it thanks a lot!!!
Copy link to clipboard
Copied
Thanks a lot!!!
Copy link to clipboard
Copied
Any recommended video or lessons so i could lean all those script please?
Thanks again!!!
Copy link to clipboard
Copied
How do you currently calculate the TOTAL field? Do you use a script?
Copy link to clipboard
Copied
Yes