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

function malfunction?

David Dunn
Registered: Oct 28 2010
Posts: 116
Answered

When I call this function (below) using "this.HideSPFields()" nothing happens. I do not get an error message, it just doesn't hide the fields in this Array as I intended. I would be grateful for a helping hand.
  
function HideSPFields()
{

var fields = new Array
 
fields[0] = "txtS.Type1-4"
fields[1] = "txtSP"
fields[2] = "cbo.SP"
fields[3] = "rdo.SP"
fields[4] = "btn.Export.SellerIndividuals"
fields[5] = "btn.Copy.SellerIndividualsToBuyerIndividuals"
 
fields.hidden = true
 
}

David D

My Product Information:
Acrobat Pro 9.4, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Accepted Answer
What is the exact error?

Your declaration of the array variable has an obvious syntax error.

You do not hide a field name(s), you hide the field object.


function HideSPFields() {
// define array of field names
var fields = new Array("txtS.Type1-4", "txtSP",
"cbo.SP", "rdo.SP", "btn.Export.SellerIndividuals",
"btn.Copy.SellerIndividualsToBuyerIndividuals");

// loop through field names
for(i = 0; i < fields.length; i++) {
// hide the field object for the named field
this.getField(fields[i]).hidden = true;
} // end for loop

return;
} // end HideSPFields

HideSPFields();

I would pass the field names to hide to the funciton, so the function is not specific to a field or group of fields.


George Kaiser

David Dunn
Registered: Oct 28 2010
Posts: 116
Thank you. I can certainly parrot that but wish I understood it. Just when feel as if I'm getting a good handle on this I learn how little I know. One step at a time. I looked unsuccessfully in the API reference on the "for()" method (?) and therefore can't follow the parameters or the concept of "passing." Is your suggested script hiding fields based on whether they are empty?

To answer your question back to me, I am not getting any error message at all. Apparently there are no syntax errors in my function, but it the function does nothing because the methodology is wrong. I am successfully using a similar approach to reset fields, but to reset fields, instead of ending the function with 'fields.hidden = true' I end it with 'this.resetForm(fields).' That works just fine, but my adaptation of it to hide fields obviously does not.

As a footnote, for a number of reasons I don't like Acrobat's "Reset a form" action, where you pick fields to reset from the "Reset a form" dialog box listing document field names. I find "Reset a form" unwieldy to use with a very long list of field names, and the "Reset a form" action seems to have a "Chameleon" character to the user-selected fields, in that if I add new fields to the document, they appear selected in the "Reset a form" dialog box even though I did not select them for inclusion in the fields to be reset.

BTW, do you know whether Acrobat X improves on Acrobat's irritating rearrangement of manually set tab order?


David D

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
David Dunn wrote:
BTW, do you know whether Acrobat X improves on Acrobat's irritating rearrangement of manually set tab order?
No it does not. This is my biggest forms-related pet peeve and I encourage you to report it as a bug. Many folks already have, but this bug has been around for years and it may take more reports for anything to be done about it. You can report it here: Adobe Bug Reporting
David Dunn
Registered: Oct 28 2010
Posts: 116
I have reported it to Adobe bug reporting twice. It irritates me to death so frequently that I would like to report it weekly just to make a statement but don't want to be unreasonable. I can see why it is your biggest.

David D

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Dave,

That's great, thanks.