These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Stopping a combo box from exporting value until checkbox is marked off

DTjava
Registered: Jun 17 2011
Posts: 21

Hi there friends!
 
I've worked out procedurally how this should work, but the code is eluding me.
 
Inititally I had a text field that (thanks to a document level script) pulled in data from a series of checkboxes. If you checked off a box, a product name gets added to the text field. Works great!
 
Now I need to expand the functionality: I am adding a combo box to every product, which gives the user a chance to add HOW MANY products they would like to add to the text field.
 
So originally: check off box, and "widget" gets added to text field.
New Goal: Check off box, select a number on combo box and "widget x 3" gets added to text field.
 
First I'll change the doc script so that the text field pulls data from the combo field, not the check box. Second, I set up the combo box to have "widget x 1, widget x 2, widget x 3, etc... as a list of options.
 
This is where I need help: I now need the combo box to only export its value if it's controlling checkbox is active. So that way, it will only submit to my document text field if the checkbox gets clicked.
 
I'm pretty sure this comes down to "Export value if "checkbox prime" is true" followed by "Else, do not export value". I'd also like to hide the combo box until the checkbox is marked off, but I can't seem to find a visibility option.
 
I have been through the API, but I'm having trouble finding the proper code and syntax. Can someone please help?
 
As always, thank you so much!
   

My Product Information:
Acrobat Pro 9.2, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
How are you currently exporting the data?
The visibility of a field can be set using the display property.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

DTjava
Registered: Jun 17 2011
Posts: 21
Phew - Well, to get into it, the text field has this calculation script:

(function() {
// array of check boxes names
var aNames = new Array("combobox prime");
// array for values from fields
var aItems = new Array(aNames.length);
// fill array with selected values
for(i = 0; i < aNames.length; i++) {
// get field value
aItems[i] = this.getField(aNames[i]).value;
// change "Off" value to null value
if(aItems[i] == "Off") { aItems[i] = ""; }
} // end loop through fields
// clear field of listed items
event.value = "";
// build string of selected items
for(i = 0; i < aItems.length; i++) {
event.value = fillin(event.value, aItems[i], "", ", \n");
} // end loop through items;
}) ();

This in turn references a doc level script that basically organizes the data into a neat little list.

So I've got it working in the sense that anything I select in the combo box drop down appears in the text field, since it's pulling the data from "combox prime".

What I need is for a script in the combobox to stop data from committing (and hence appearing in the text field) UNTIL the corosponding checkbox is true. Ideally I'd like the same code to make the normally hidden combo box visible until the checkbox is true.

So in combobox prime:
Make visible if checkbox prime is true
Commit selection immediately if checkbox prime is true
else, do nothing.

My other script will take care of the rest.


I've tried this so far:
var checkbox = this.getField("checkbox prime").value;
if (checkbox = "true" ) f.commitOnSelChange = true;

But it's not working - Don't think I'm working with the right commands here.

Any ideas?





try67
Expert
Registered: Oct 30 2008
Posts: 2398
First of all, in order to test a value you must use the comparison operator "==", not the assignment operator "=".
Also, did you set the value of the check-boxes to be "true" when selected? The default value is "Yes".

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

DTjava
Registered: Jun 17 2011
Posts: 21
Keeps telling me "f" is not defined...but again, I'm not even sure if "commitOnSelChange" is what I'm after here.
DTjava
Registered: Jun 17 2011
Posts: 21
wait - F is the function! Duh. so:

var checkbox = this.getField("checkbox prime").value;
if (checkbox = "true" ) true.commitOnSelChange;

And I see what you mean about the checkbox. I assumed it was either True or False for On or Off. But I see now there's a specific export value.


DTjava
Registered: Jun 17 2011
Posts: 21
Still not getting anything. The value from the combobox is exporting regardless of the checkbox being on or off. I think I need an else statement? How can I tell the combobox "else - do nothing"?