My Acrobat PDF form requires conditional processing based on the input value of a ComboBox.
The first ComboBox (nStair_Depth) has two values; 10 or 12 (default = 10). Its value determines the visibility of two other ComboBoxes.
If nStair_Depth = 10, ComboBox (nPlatform_Depth10) should be visible with a default value of 30.
If nStair_Depth = 12, ComboBox (nPlatform_Depth12) should be visible with a default value of 30.
P.S. These nPlatform_Depthx ComboBoxes have different selectable item list values with overlap on only two common values; 30 and 60.
In the Actions dialog for the nStair_Depth ComboBox I've create an Action with Select Trigger = Mouse Up, Select Action = Run a JavaScript and I entered the following JavaScript code:
if (this.getField("nStair_Depth").value==10)
{
this.getField("nPlatform_Depth12").display = display.hidden;
this.getField("nPlatform_Depth10").display = display.visible;
this.getField("nPlatform_Depth10").value = 30;
}
else
{
this.getField("nPlatform_Depth10").display = display.hidden;
this.getField("nPlatform_Depth12").display = display.visible;
this.getField("nPlatform_Depth12").value = 30;
}
At startup the nStairs_Depth ComboBox is displayed with a default value of 10, the nPlatForm_Depth10 ComboBox is visible with a default value of 30 and the nPlatform_Depth12 ComboBox is hidden with a default value of 30. Good.
However, changing the value of nStair_Depth from 10 to 12 does not immediately change the visibility of the nPlatform_Depthx ComboBoxes. However, if I re-enter the nStair_Depth ComboBox and re-select 12, then the code executes, the nPlatform_Depth10 ComboBox becomes hidden, the nPlatform_Depth12 ComboBox becomes visible and the default value of 30 is displayed. Switching back to 10 from 12 requires the same re-select process to show the appropriate nPlatform_Depth10 ComboBox with it's default value of 30.
Ideally, I'd like it function as follows:
Only on actually "changing" the nStairs_Depth value does the appropriate nPlatform_Depthx ComboBox appear immediately (without any extra manipulation of the nStair_Depth field as described above). If I simply select the nStair_Depth field, nothing should happen unless I actually "change" the value.
Upon changing the nStair_Depth value, if the previous nPlatform_Depthx value was 30 or 60 it should become the new value for the newly visible nPlatform_Depthx ComboBox ... otherwise the default value of 30 should be set. I know the reset-value logic is different from the ComboBox visibility issue but I'll eventually need to deal with both issues.
This visibility problem seems to me to be a function of finding the proper way to trigger the execution of the Run Javascript event to coincide with an actual "change" to the value of the NStair_Depth field and no other event.
Any suggestions would be greatly appreciated.
For more information on working with combo boxes and JavaScript, see Thom Parker's articles in the Tutorial section here. Here is a link to the first one: http://www.acrobatusers.com/tutorials/2007/js_list_combo_livecycle/
George