Solved

Using commitOnSelChange

Posted on 2004-08-05
10
405 Views
Last Modified: 2008-02-26
Does anyone know the the syntax and an example of how to use the field property commitOnSelChange. I have a list box called "search" that i am using a keystroke event with and I dont' want the value to commit to a textbox untill the field loses focus. But i can't get it to work, PLEASE HELP!
0
Comment
Question by:jerrycsakanyjr
  • 6
  • 4
10 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11726494
The property controls the setting "Commit selected value immediately", that you can find on th e"Options" tab on the "Combo Box Properties" user interface. This is how you would use it:

var f = this.getField("Combo Box1");
f.commitOnSelChange = true; // or use false to disable the feature

When it's set to true, then whenever you change the selection, JavaScript will call your "On Blur" handler. If it's set to false, this handler is only called when you actually leave the control by tabbing to the next control, or submitting the form. The difference in behavior is important: In the first case, you call the handler function for every single setting that you touch (e.g. if you select a few values before you settle on the final value, your handler will be called multiple times vs. just once if it's set to false). So, if you want to copy the selected value to a text field, and you want to reflect the change immediately, you need to set it to true, if you only want to see the change after the field loses focus (as you state), you need to set it to false. You don't have to use this field property, you can also use the properties dialog to make the change.
0
 

Author Comment

by:jerrycsakanyjr
ID: 11726591
Where would i insert the code for the f.commitOnSelChange = false; and can it be part of a keystroke even of a listbox.  Here is my code so far i just need an insertion point.

if (!event.willCommit) {
      var f = this.getField("county");
        var g = this.getField("district");
        var t = this.getField("titleno");
              

      /* In a keystroke event, event.change contains the non-export value of
      ** the item selected by the user. */
      switch (event.change) {
      case "Suffolk":
              f.setItems(["Suffolk"]);
                        g.setItems(["Eastern"]);
                       break;
                case "Nassau":
                        f.setItems(["Nassau"]);
                        g.setItems(["Eastern"]);
                               break;
                case "Kings":
                        f.setItems(["Kings"]);
                        g.setItems(["Eastern"]);
                break;
                case "Queens":
                        f.setItems(["Queens"]);
                        g.setItems(["Eastern"]);
                break;
                case "Richmond":
                        f.setItems(["Richmond"]);
                        g.setItems(["Eastern"]);
                break;
                case "Broome":
                        f.setItems(["Broome"]);
                        g.setItems(["Northern"]);
                break;
                case "Cayuga":
                        f.setItems(["Cayuga"]);
                        g.setItems(["Northern"]);
                break;
                case "Albany":
                        f.setItems(["Albany"]);
                        g.setItems(["Northern"]);
                break;
                case "Bronx":
                        f.setItems(["Bronx"]);
                        g.setItems(["Southern"]);
                break;
                case "Yates":
                        f.setItems(["Yates"]);
                        g.setItems(["Western"]);
                break;
                case "Allegheny":
                        f.setItems(["Allegheny"]);
                        g.setItems(["Western"]);
                break;
                case "Chenango":
                        f.setItems(["Chenango"]);
                        g.setItems(["Northern"]);
                break;
                case "Clinton":
                        f.setItems(["Clinton"]);
                        g.setItems(["Northern"]);
                break;
                case "Columbia":
                        f.setItems(["Columbia"]);
                        g.setItems(["Northern"]);
                break;
                case "Cortland":
                        f.setItems(["Cortland"]);
                        g.setItems(["Northern"]);
                break;
                case "Delaware":
                        f.setItems(["Delaware"]);
                        g.setItems(["Northern"]);
                break;
                case "Essex":
                        f.setItems(["Essex"]);
                        g.setItems(["Northern"]);
                break;
                case "Franklin":
                        f.setItems(["Franklin"]);
                        g.setItems(["Northern"]);
                break;
                case "Fulton":
                        f.setItems(["Fulton"]);
                        g.setItems(["Northern"]);
                break;
                case "Greene":
                        f.setItems(["Greene"]);
                        g.setItems(["Northern"]);
                break;
                case "Hamilton":
                        f.setItems(["Hamilton"]);
                        g.setItems(["Northern"]);
                break;
                case "Herkimer":
                        f.setItems(["Herkimer"]);
                        g.setItems(["Northern"]);
                break;
                case "Jefferson":
                        f.setItems(["Jefferson"]);
                        g.setItems(["Northern"]);
                break;
                case "Lewis":
                        f.setItems(["Lewis"]);
                        g.setItems(["Northern"]);
                break;
                case "Madison":
                        f.setItems(["Madison"]);
                        g.setItems(["Northern"]);
                break;
                case "Montgomery":
                        f.setItems(["Montgomery"]);
                        g.setItems(["Northern"]);
                break;
                case "Oneida":
                        f.setItems(["Oneida"]);
                        g.setItems(["Northern"]);
                break;
                case "Onondaga":
                        f.setItems(["Onondaga"]);
                        g.setItems(["Northern"]);
                break;
                case "Oswego":
                        f.setItems(["Oswego"]);
                        g.setItems(["Northern"]);
                break;
                case "Otsego":
                        f.setItems(["Otsego"]);
                        g.setItems(["Northern"]);
                break;
                case "Rensselaer":
                        f.setItems(["Rensselaer"]);
                        g.setItems(["Northern"]);
                break;
                case "Saint Lawrence":
                        f.setItems(["Saint Lawrence"]);
                        g.setItems(["Northern"]);
                break;
                case "Saratoga":
                        f.setItems(["Saratoga"]);
                        g.setItems(["Northern"]);
                break;
                case "Schoharie":
                        f.setItems(["Schoharie"]);
                        g.setItems(["Northern"]);
                break;
                case "Schenctedy":
                        f.setItems(["Schenctedy"]);
                        g.setItems(["Northern"]);
                break;
                case "Tioga":
                        f.setItems(["Tioga"]);
                        g.setItems(["Northern"]);
                break;
                case "Tompkins":
                        f.setItems(["Tompkins"]);
                        g.setItems(["Northern"]);
                break;
                case "Ulster":
                        f.setItems(["Ulster"]);
                        g.setItems(["Northern"]);
                break;
                case "Warren":
                        f.setItems(["Warren"]);
                        g.setItems(["Northern"]);
                break;
                case "Washington":
                        f.setItems(["Washington"]);
                        g.setItems(["Northern"]);
                break;
                case "Dutchess":
                        f.setItems(["Dutchess"]);
                        g.setItems(["Southern"]);
                break;
                case "New York":
                        f.setItems(["New York"]);
                        g.setItems(["Southern"]);
                break;
                case "Orange":
                        f.setItems(["Orange"]);
                        g.setItems(["Southern"]);
                break;
                case "Putnam":
                        f.setItems(["Putnam"]);
                        g.setItems(["Southern"]);
                break;
                case "Rockland":
                        f.setItems(["Rockland"]);
                        g.setItems(["Southern"]);
                break;
                case "Sullivan":
                        f.setItems(["Sullivan"]);
                        g.setItems(["Southern"]);
                       
                break;
                case "Westchester":
                        f.setItems(["Westchester"]);
                        g.setItems(["Southern"]);
                break;
                case "Waters":
                        f.setItems(["Waters"]);
                        g.setItems(["Southern"]);
                break;
                case "Cattaraugus":
                        f.setItems(["Cattaraugus"]);
                        g.setItems(["Western"]);
                break;
                case "Chautauqua":
                        f.setItems(["Chautauqua"]);
                        g.setItems(["Western"]);
                break;
                case "Chemung":
                        f.setItems(["Chemung"]);
                        g.setItems(["Western"]);
                break;
                case "Erie":
                        f.setItems(["Erie"]);
                        g.setItems(["Western"]);
                break;
                case "Genesee":
                        f.setItems(["Genesee"]);
                        g.setItems(["Western"]);
                break;
                case "Livingston":
                        f.setItems(["Livingston"]);
                        g.setItems(["Western"]);
                break;
                case "Monroe":
                        f.setItems(["Monroe"]);
                        g.setItems(["Western"]);
                break;
                case "Niagara":
                        f.setItems(["Niagara"]);
                        g.setItems(["Western"]);
                break;
                case "Ontario":
                        f.setItems(["Ontario"]);
                        g.setItems(["Western"]);
                break;
                case "Orleans":
                        f.setItems(["Orleans"]);
                        g.setItems(["Western"]);
                break;
                case "Schuyler":
                        f.setItems(["Schuyler"]);
                        g.setItems(["Western"]);
                break;
                case "Seneca":
                        f.setItems(["Seneca"]);
                        g.setItems(["Western"]);
                break;
                case "Steuben":
                        f.setItems(["Steuben"]);
                        g.setItems(["Western"]);
                break;
                case "Wayne":
                        f.setItems(["Wayne"]);
                        g.setItems(["Western"]);
                break;
                case "Wyoming":
                        f.setItems(["Wyoming"]);
                        g.setItems(["Western"]);
                break;

}
}
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 250 total points
ID: 11726666
YOu should do this as part of your form setup (either at design time, or when the document gets loaded). I don't know if you can do it in the keystroke script, but because the keystroke script is getting information about whether the keystroke is part of a comit or not, I doubt it, and it sounds dangerous to even try this. As I said, you can set this setting on the properties dialog. If I would set it in JavaScript, I would create a document level JavaScript, give it a name like "InitDocument", and then remove the function stub that is automatically created. If you enter yoru JavaScript commands outside of a function body, they will get executed at the time the document loads.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:jerrycsakanyjr
ID: 11727014
What i am trying to accomplish is append a 1 or 2 character postfix to the end of the value of the field called titleno? Maybe i could do a check on the value of that field. Something like ...Starting from the end of the string check for the any alpha characters if they exist replace with the value of the selection otherwise just append the value of the selection. Is this feasible, or am i just having pipe dreams again. :)
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11727943
You can use regular expressions to extract yoru postfix code. What's the format of the whole string?
Are you familiar with regular expressions? This is a standard JavaScript feature (or, to be more accurate, it's a standard feature of a lot of languages and enviroenments), which means that you will not find any documentation in the Acrobat SDK.
0
 

Author Comment

by:jerrycsakanyjr
ID: 11728075
the format of the string before any postfix is added:

BELLE-16051 <-- is in a field called titleno
 
then a postfix would be appended to that string depending on the selection made in the listbox ie, if Suffolk is choosen S would be appended, if Nassau is selected N would be appended, if Orleans is selected OR is appended...ect. so the resulting string would be BELLE-16051S  or BELLE-16051N, or BELLE-16051OR

 
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11728107
Is the format always:
A number of letters - a dash - a number of digits - the one or two letter postfix?

0
 

Author Comment

by:jerrycsakanyjr
ID: 11728133
yes
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11728373
Here is some code that applies a regular expression to a string that's read from an input text field. The postfix is then written to another text box:

// get the input and output fields

var inp = this.getField("Text1");
var out = this.getField("Text2");

var in_string = inp.value;

// apply regular expression
var reg = /([^-]+)-(\d+)(.+)/i;    // this is a one or more characters which are not '-', followed by one dash
                                                // followed by a one or more digits, followed by one or more other
                                                // characters. There are three groups in this regular expression (indicated by
                                                // "(...)", what you are lookign for is in the third group.

var ar = reg.exec(in_string);       // apply the reg exp.

if (ar == null)
{
    out.value = "";                       // if we did not find the pattern, then output an empty string
}
else
{
     out.value = ar[3];                  // otherwise print the third group content
}
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 11728381
BTW: This site has some good samples for browser JavaScript. But it's easy to apply it to Acrobat JavaScript as well:
http://www.webreference.com/js/column5/index.html
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
convert pdf to e-book 1 948
Computer freezes up when trying to add a comment to a PDF file 5 131
what font behind pdf 32 150
How to open a zip file 4 101
The ability to edit PDF documents can be useful, however it may not be a straight forward process. Many non-technical people don't realise that a PDF document is basically an image rather than a text file, even if it contains nothing but text. If…
Power PDF (http://www.nuance.com/for-business/document-imaging-and-scanning/power-pdf-converter/index.htm) is the newest product from the Document Imaging division of Nuance Communications (http://www.nuance.com/). It is available in two editions — …
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question