Custom calculation script for A1:
var q1 = this.getField("Q1").valueAsString;
if (q1=="Yes") event.value = 1;
else if (q1=="No") event.value = 2;
else event.value = "";
For A4 you can use the built-in option for calculating a sum of fields under the first section of the Calculate tab.
Thank you so much, it works. Q6 is more than Yes and No question, it has the 1) within 3 months, 2) 1-5 yeas or more, 3) Ho History. I tried to change the Yes and no to the "text" but doesn't work.
If the texts in the script and in the field are EXACTLY (including upper/lower-case and spaces) the same then it should work.
This is what I got in Q6, "within 3 months", "within 1 year, "1-5 yrs or more" and "no history"
Here is the JS for A6:
if (q6=="within 3 months") event.value = 13;
else if (q6=="within 1 year") event.value = 6;
else if (q6=="1-5 yrs or more") event.value = 1;
else if (q6=="no history") event.value = 0;
event.value = "";
Thank you so much.
I suggest you use a drop-down field instead of a text field. It will make the room for errors much smaller...
That is what I did for all the questions, a drop-down box.
the Yes, No and N/A works, but not for this Q6.
I did deleted and reset the drop box and still not working.
Is the option to commit the selected value of the drop-downs selected? If so, and there are no errors in the JS console (Ctrl+J), then could you share the file?
Thank you so very much for helping me in this matter.
Here is the link to this file: https://files.acrobat.com/a/preview/95c925c9-8118-4f4e-8d2f-07322a2fa4a6
Hope you can find out what's wrong with this file.
For some reason you removed the word "else" at the start of the last line, so the field's value is always set as an empty string... Add it and it will work.
Thank you so much for all your help in this matter. It does work and again Thanks.