Copy link to clipboard
Copied
I have a form that contains 6 different fields. I would like them to show values within ranges of a given answer. The field ranges are 5-8, 9-13, 14-17, 18-21, 22-25, and 26-30.
If the value falls between any given range, I would like for my form to populate the number in that range. The other fields should remain blank with no data showing unless the value moves to one of the other ranges. If it does, then the original field should blank out.
Example: for the field of 5-8: if I have a value of 6, then 6 should populate in the 5-8 text box. If the value changes to 12, the 5-8 text box should return to blank, and the 9-13 text box should show the value of 12.
As the values change, the other field range text boxes should react accordingly.
Here's my main problem- I can get the values to populate with the data using if and else if, but for some reason the blocks don't return to blank. They basically show residue numbers in the fields that the user would have to go and manually clear out. My scripting looks like this:
For the 5-8 field:
var v1 = this.getField("C/C Total Score").value;
if (v1 <= 0) {
event.value = " ";}
else if (v1 >=5 && v1 <=8) {
event.value = (v1); }
else if (v1 >8) { event.value = " ";}
For the 9-13 field:
var v1 = this.get.Field("C/C Total Score").value;
if (v1 >= 9 && v1 <= 13) {
event.value = (v1);}
else if (v1 >=13 &&v1 <=9) {event.value = " "; }
else if (v1 >13) {event.value = " "; }
The other range fields look similar except for number changes in the script.
Is there anyone that can help me achieve what I need to do?
You have overlapping conditions. For example, in the second script if the value is 9 it falls in both the first and second if-conditions. That's not good.
And you have a syntax error there, as well. You wrote "get.Field" instead of "getField". That should display an error message in the JS Console.
Also, your code is unnecessarily cumbersome. It could be optimized to just this:
...var v1 = Number(this.getField("C/C Total Score").valueAsString);
if (v1 >= 9 && v1 <= 13) event.value = v1;
else event.value
Copy link to clipboard
Copied
You have overlapping conditions. For example, in the second script if the value is 9 it falls in both the first and second if-conditions. That's not good.
And you have a syntax error there, as well. You wrote "get.Field" instead of "getField". That should display an error message in the JS Console.
Also, your code is unnecessarily cumbersome. It could be optimized to just this:
var v1 = Number(this.getField("C/C Total Score").valueAsString);
if (v1 >= 9 && v1 <= 13) event.value = v1;
else event.value = " ";
Copy link to clipboard
Copied
I will give this a shot tomorrow and see if it works. Hopefully it does and I'll be able to apply it to the other fields. I appreciate the quick response!
Copy link to clipboard
Copied
Try67,
I appreciate the help! It worked like a charm for all of the blocks I needed it to! If you're willing, I have some other issues with other documents I'd like to ask your assistance on. They have to do with scripting as well.
Copy link to clipboard
Copied
Try67,
I am a co-work of lambo889, and we are working on the same PDF. The above scripted fixed the issue that lambo889 address. But we have one more to address. One of the pages is for Leadership evaluations, it has 5 columns with a possible score of 1 to 5 points. There are 21 rows of different classes, in total 105 different cells. Adding them up was the easy part, now I want to convert the accumulated or total points earned to a GPA %. i.e. 493 / 525 = 93.9%. This the script we are needing is for only one cell and duplicated cell on another page, simple copy and paste after the script works. We need a scrip takes the "Total per lessonFINAL GRADE Ex" as the numerator and a never changing dominator of 525.
Copy link to clipboard
Copied
Use this:
event.value = Number(this.getField("Total per lessonFINAL GRADE Ex").valueAsString) / 525;
Copy link to clipboard
Copied
Try67,
Last issue....hopefully. You scripted worked, thanks you. Now with that GPA %, there is a drop down block with four options, >>>>, Unsatisfactory, Satisfactory, and Superior. With the blow script, it giving me a Syntax error.
var v1 = this.getField("Non-GPA Contribution to Group Work") . value;
if (v1 <= 0) {
event.value = ">>>>>";
else if (v1 >= 1% && v1<= 69%) {
event.value = "Unsatisfactory";
}
else if (v1 >= 70% && v1<= 89%) {
event value = "Satisfactory";
}
else if (v1 >= 90% && <= 100%) {
event value = "Superior";
}
Thanks
Copy link to clipboard
Copied
Drop the percentage symbols.
Copy link to clipboard
Copied
How do I drop it from the original block I asked about " Non_GPA Contribution to Group Work"? I had to chose under the "Format" tab for that cell, to not get a 1.0, but the percentage opinion to get a 100.00%?
Copy link to clipboard
Copied
Then the value is between 0 and 1, not 0 and 100.
Copy link to clipboard
Copied
I am trying to change this under this Format option.
I want it to display only the 92.38, WITHOUT the % symbol.
But any other option changes it to either 0.9238 or just a whole number of 1 or 1.0.
This script is from the block Dropdown block gets "Non-GPS Contribution to Group Work" from, but since the only way I know of to get it to display a 92.38 is with the percentage option, this script isn't working for the drop down, due the % symbol.
Copy link to clipboard
Copied
The Format setting doesn't change the actual value, only how it is presented.
If you want the value to be between 0 and 100 you need to multiply it by 100 (and set the Format to None).
Copy link to clipboard
Copied
The right one is what is displayed when "NONE" is selected. I need it to say 100.00 or just 100, and the left is the same under "NONE" and need it to display under "GRADE" a 98.48.
Copy link to clipboard
Copied
I told you, multiply the result by 100.
If your current code is this:
event.value = Number(this.getField("Total per lessonFINAL GRADE Ex").valueAsString) / 525;
Change it to:
event.value = (Number(this.getField("Total per lessonFINAL GRADE Ex").valueAsString) / 525) * 100;
Copy link to clipboard
Copied
YOUR AMAZING!!! That worked. Thank you for all the help the last few days! You helped us make an amazing product.
Michael
Copy link to clipboard
Copied
Thanks again!!!