Copy link to clipboard
Copied
I have developed a document DWH script to define the efficiency of the Domestic Water Heater (DWH) and set whether or not it is co-vented along with other combustion equipment. The latter two properties are dependent on DWH energy source and DWH type used.
Following one of your published examples, I managed to output the correct DWH efficiency for each pair of DWH energy source and DWH type; however, I was unable to get the correct output for the co-vented field. This should be either "Yes" or "No". I am sure I am making a very amateurish mistake, but I cannot figure out what.
Could you help?
Thank you
So you really need to read these articles, they explain all of this is detail
https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm
https://acrobatusers.com/tutorials/change_another_field/
https://acrobatusers.com/tutorials/js_list_combo_livecycle/
The problem is in two places.
First, the script in the fuel dropdown, that sets the list items in the second dropdown. The items are an array with 3 entries. The field.setItems function only allows the items to be a single value or an
...Copy link to clipboard
Copied
So you really need to read these articles, they explain all of this is detail
https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm
https://acrobatusers.com/tutorials/change_another_field/
https://acrobatusers.com/tutorials/js_list_combo_livecycle/
The problem is in two places.
First, the script in the fuel dropdown, that sets the list items in the second dropdown. The items are an array with 3 entries. The field.setItems function only allows the items to be a single value or an array with two entries. So it's combining them into a single string and there is no export value, i.e. the parameters that need to be transfered to the text fields are not directly available for transfer. The data organization needs to be modified so this data is available.
Second, the two functions used in the second dropdown are called on the WillCommit Keystroke. In this event the selected value is in the event.value property, event.changeEx is not defined for this event so it is empty. But even if there was an export value, and it was available in event.changeEx, both functions use the same value, so the both text fields would recieve the same thing. Again the data needs to be reorganized so only the list of equipment names is shown in the second dropdown, and the efficiency and coventing values are separted out for transfer.
I modifed the code in the document level script in a couple of ways. First I changed the data organization for the "Oil" entry. You will need to change the rest in the same way. Notice that I made each enty an array of two strings. The second is two values separated by a comma.
Next I combined both of the functions that set the text fields into a single function, that uses the non-committed Keystroke event. In this event event.changeEx contains the export value. Which is then split into two parts, with each part going to a different text field.
var oDWHEnergySources = {
NG: [ ["-","None","None"], ["Conventional Tank without pilot",0.55,"Yes"], ["Conventional Tank with pilot",0.55,"Yes"], ["Tankless Coil",.48,"No"],["Instantaneous-direct vent cond",0.83,"No"],["Instantaneous w/ Pilot",0.83,"No"],["Instantaneous condensing",0.80,"No"],
["Induced Draft Fan with ignitor",0.57,"No"],["Induced Draft Fan with pilot",0.57,"No"],
["Direct vent (sealed)",0.58,"No"],["Condensing",0.86,"No"]],
Oil: [ ["-","None,None"], ["Conventional tank","0.53,Yes"],["Tankless Coil","0.40,No"]],
Electricity: [ ["-","None","None"], ["Conventional Tank",0.82,"No"], ["Conserver Tank",0.87,"No"], ["Instantaneous",0.94,"No"],["Tankless Heat Pump",190,"No"],["Heat Pump",190,"No" ]],};
function SetDWHTypeEntries()
{
if(event.willCommit)
{
var lst = oDWHEnergySources[event.value];
if( (lst != null) && (lst.length > 0) )
this.getField("DWHType").setItems(lst);
else
{
this.getField("DWHType").clearItems();
}
this.getField("DWHEfficiency").value = 0;
this.getField("Covented").value = 0;
}
}
function SetDWHEfficiency()
{
if(!event.willCommit)
{
var aParts = event.changeEx.split(",");
if(aParts.length == 2){
this.getField("DWHEfficiency").value = aParts[0];
this.getField("Covented").value = aParts[1];
}
}
}
Copy link to clipboard
Copied
Thank you Thom, it works now.
I will definitely, read the references you mentioned in your message.
Khalique