Copy link to clipboard
Copied
I coordinate a girls club (with 6 club levels from pre-K to 12th grade) at a small church and have created a 4 page
order form with fillable fields. Since I am on a limited budget for the supplies and awards for the girls, I'm using
PDFill to create the fields on the form. I am new to setting up combo boxes, but have some experience with the
math aspect. The form is set to calculate the number of pages in use for the page __ of __ field as well as
display the subtotal of the pages on page 1 and to calculate the postage and handling based on the amount
ordered. The form also has an inventory column and a need column which are used to determine how many of
each item to order, then compute the total cost for each item being ordered. Now I want to make filling in the item
descriptions easier.
A template form with each item already filled in will be copied to use for ordering. The issue is the activity pages
and awards for each of the levels. The number of units and years for the levels vary, but for simplicity I will use a
club with 9 units and a rotation of 3 years. In the script the "R" stands for the club level, the "bg" stands for
the award earned (on a different line it will be "ap" for activity page). Column is based on a Unit Rotation form for
tracking what units will be taught in the current year. The only thing needed from that form is the knowledge of
how many columns the current club level has in it's rotation.
Results needed: If column 2 of the combo box (cBx152) is selected, the related description needs to show in
desc152 text field and the item number needs to show in the cat152 field. Also, if for some reason a different unit
needs to be done, the user needs to be able to manually enter it. cBx152 will need to be duplicated for the other
8 units which will range from 153 to 162.
I have tried both of the following scripts, but neither of them puts the desired info in desc152 or cat152.
Var ComboVal = this.getField("cBx152").valueAsString;
if(Val(ComboVal) = 1) {
this.getField("desc152").value = "R bg 1 Bears"
this.getField("cat152").value = "150864"
}
else if(Val(ComboVal) = 2) {
this.getField("desc152").value = "R bg 2 Ladybugs"
this.getField("cat1502").value = "150876"
}
else if(Val(ComboVal) = 3) {
this.getField("desc152").value = "R bg 3 Dolphins"
this.getField("cat152").value = "157154"
}
else {
this.getField("desc152").value = ""
this.getField("cat152").value = ""
}
alternate script:
Var ComboVal = this.getField("cBx152").valueAsString;
switch(ComboVal) { //use val or right to test number part only
Case "1 R bg Column 1":
this.getField("desc152").value = "R bg 1 Bears"
this.getField("cat152").value = "150864 b"
break;
Case "2 R bg Column 2":
this.getField("desc152").value = "R bg 2 Ladybugs"
this.getField("cat1502").value = "150876 l"
break;
Case "3 R bg Column 3":
this.getField("desc152").value = "R bg 1 Dolphins"
this.getField("cat152").value = "157154 d"
break;
Default:
this.getField("desc152").value = ""
this.getField("cat152").value = ""
break;
}
Copy link to clipboard
Copied
I finally figured out how to do it (the code is listed below). Now how do I get it to show the propagated text immediately and is there a way to prevent tabbing to the combo box, but allow a mouse click to access it?
var i = this.getField("cBx152").currentValueIndices;
if(i == 0) { //keep field contents
this.getField("desc152").value = desc152;
this.getField("cat152").value = cat152;
}
else if(i == 1) {
this.getField("desc152").value = "R bg 1 Bears";
this.getField("cat152").value = "150864";
}
else if(i == 2) {
this.getField("desc152").value = "R bg 2 Ladybugs";
this.getField("cat152").value = "150876";
}
else if(i == 3) {
this.getField("desc152").value = "R bg 3 Dolphins";
this.getField("cat152").value = "157154";
}
else { //clear field contents
this.getField("desc152").value = "";
this.getField("cat152").value = "";
}
Copy link to clipboard
Copied
I realized my condition in the first script had = instead of ==, but with that correction it still doesn't put anything in desc152 or cat152
Copy link to clipboard
Copied
I finally figured out how to do it (the code is listed below). Now how do I get it to show the propagated text immediately and is there a way to prevent tabbing to the combo box, but allow a mouse click to access it?
var i = this.getField("cBx152").currentValueIndices;
if(i == 0) { //keep field contents
this.getField("desc152").value = desc152;
this.getField("cat152").value = cat152;
}
else if(i == 1) {
this.getField("desc152").value = "R bg 1 Bears";
this.getField("cat152").value = "150864";
}
else if(i == 2) {
this.getField("desc152").value = "R bg 2 Ladybugs";
this.getField("cat152").value = "150876";
}
else if(i == 3) {
this.getField("desc152").value = "R bg 3 Dolphins";
this.getField("cat152").value = "157154";
}
else { //clear field contents
this.getField("desc152").value = "";
this.getField("cat152").value = "";
}
Copy link to clipboard
Copied
Why you using currentValueIndices?
Are 0,1,2...etc export values of dropdown (combobox) field?
Use script as 'Custom calculation script' of dropdown field also in dropdown field properties, under 'Options' tab , check 'Commit selected value immediately'.
In this case, the script should look like this:
if(event.value == "1"){
this.getField("desc152").value = "R bg 1 Bears";
this.getField("cat152").value = "150864";
}
//...etc
Not sure what you tried to do if value is 0?
Copy link to clipboard
Copied
currentValueIndices is the number of the choice selected, beginning with 0 for the first option, so this comb box would have values of 0,1,2,3.
I could probably do nothing if Custom is selected (i == 0) since no change is to be made. That option is a precaution to prevent erasing custom info in case the combo box is selected and no changes are desired. It is basically the same as if '- Select One -' is put there and nothing is selected.
I guess PDFill doesn't have 'Commit selected value immediately'.
Thank you for your help. Other than the Commit issue I have this question resolved with the code above and the option to leave the fields unchanged. I have a different issue related to these combo boxes, but I will post it in a new thread. I don't know how to close this thread.
Copy link to clipboard
Copied
Instead of currentValueIndices you could set export values.
Condition for 0 is not correct since both desc152 and cat152 are not declared variables, and they are not strings, so you will get error in console.
Copy link to clipboard
Copied
I couldn't get export values to work. I don't know if condition 0 produces errors, but it works for my purposes, however, as I stated in a previous post, I don't need to do anything if the condition = 0.
Thank you for the info.

