15 Replies Latest reply on Aug 12, 2015 2:00 PM by gkaiseril

    RouterForms Date Picker Calendar questions

    Sean.twyman Level 1

      so I using the RouterForms Calendar feature, and attached it to a field called "Date". If i tab tot he date field the calendar automatically comes up which is not preferable but i can live with. However the calendar with remain up unless i physically click on a date, so if i tab past that field or manually type in a date, the calendar does not go away. 

       

      2nd if i do pick a date, how come it does not set focus on the next field? and how do i fix that?

       

      3rd - i also have a "Day" field  that i would like to auto populate based on the date that is either entered from the "Date" field where the calendar is, or more importantly if i pick a date from the calendar attached to the "Date" field.

       

      I know this is not a part of Acrobat but I am hoping someone with know how this works.

        • 1. Re: RouterForms Date Picker Calendar questions
          try67 MVP & Adobe Community Professional

          1. That's how form fields work in PDF files. There's no real way around it.

          2. It's not set up to do that that. You could add your own code to it that does.

          3. You can copy the value of the Date field to the Day field, by using this code as the custom calculation script for the latter:

          event.value = this.getField("Date").valueAsString;

          • 2. Re: RouterForms Date Picker Calendar questions
            George_Johnson MVP & Adobe Community Professional

            Not related to your question, but I'd recommend switching to the similar date picker that you can get here: http://www.pdfscripting.com/public/FreeStuff/PDFSamples/JSPopupCalendar.pdf

             

            It has important bug fixes and is a bit more flexible.

            • 3. Re: RouterForms Date Picker Calendar questions
              Sean.twyman Level 1

              1. could i make the text field read only so that the user has to use the calendar?

               

              2.  i tried to see in the code for the calendar on where i could set the focus on mouse up or blur, but i am unsuccessful in finding anything that make sense.

               

              3. That works, however i believe i wasn't clear enough in my original question. I would like the day field to take the information from the date field and figure out what day of the week it is, so if i click on today's date from the calendar it gets posted to the "Date" field as 8/5/2015. The "Day" field should then show "Wednesday". If that's even possible.

              • 4. Re: RouterForms Date Picker Calendar questions
                George_Johnson MVP & Adobe Community Professional

                Making the field read-only is commonly done. Since the calendar popup won't work on many PDF viewers that otherwise have some support for forms, it may be a good idea to not make it read-only, so that users will be able to manually enter a date.

                 

                If you're going to stick with the FormRouter version, you should at least find the code that sets the number of days in August to 30 and change it to 31.

                • 5. Re: RouterForms Date Picker Calendar questions
                  Sean.twyman Level 1

                  No i changed to your suggestion, however i am running into an issue when when the calendar is displayed, it overlaps with another field making the dates difficult to click on.  so  i was thinking that when the user clicks on the show calendar button that it could maybe hide the other field until the calendar is gone but im not sure how to do that.

                   

                  which also brings me  back to my original 2nd question is how to set the focus when i have selected the date and the calendar goes away?

                   

                  and what happens if i click on the calendar and then decide i don't want to pick a date. how do i cancel and make the calendar go away?

                  • 6. Re: RouterForms Date Picker Calendar questions
                    George_Johnson MVP & Adobe Community Professional

                    Instead of hiding them you could set them to read-only, but this would involve some customization of the code, as would the additional features you want. I realize this is vague, but it's not a small amount of work and I can't succinctly tell you exactly what to do.

                    • 7. Re: RouterForms Date Picker Calendar questions
                      Sean.twyman Level 1

                      the issue is that they are already read only and it still interferes with the calendar

                      • 8. Re: RouterForms Date Picker Calendar questions
                        Sean.twyman Level 1

                        i got the field to hide when the calendar is showed by editing the doc level JavaScript.

                         

                        i changed the very end to:

                        function FormRouter_SetupCalendar(Showed)
                        {
                          var isShowed;
                          if(Showed)
                            isShowed = false;
                          //getField("ClockInM").display = true; 
                          else
                            isShowed = true;
                          getField("ClockInM").display = true;  
                          getField("FR_00000_Calendar.CalendarHead").hidden = isShowed;
                          getField("FR_00000_Calendar.CalendarYear").hidden = isShowed;
                          getField("FR_00000_Calendar.CalendarFrame").hidden = isShowed;
                          getField("FR_00000_Calendar.CalendarMonth").hidden = isShowed;
                          var oDate = FormRouter_getWorkingDate();
                          FormRouter_SetDays(oDate.getMonth() + 1, oDate.getFullYear());
                        

                        but if i uncomment line 6 above i get a syntax error

                        • 9. Re: RouterForms Date Picker Calendar questions
                          try67 MVP & Adobe Community Professional

                          The "display" property is not a boolean.

                           

                          On Thu, Aug 6, 2015 at 12:41 AM, Sean.twyman <forums_noreply@adobe.com>

                          • 10. Re: RouterForms Date Picker Calendar questions
                            Sean.twyman Level 1

                            George_Johnson wrote:

                             

                            Not related to your question, but I'd recommend switching to the similar date picker that you can get here: http://www.pdfscripting.com/public/FreeStuff/PDFSamples/JSPopupCalendar.pdf

                             

                            It has important bug fixes and is a bit more flexible.

                            I changed to your suggestion however, i have another question relating to not only the calendar but my whole sheet. I would like to make duplicates of this sheet in the same form, so right now this is basically a 1 day time sheet, but i want to make it for 5 days so i need to copy this 4 times, but as you are aware if i just duplicate it then whatever i put on the first page copies to all the other pages. So how do i duplicate it and have all the fields and JavaScript for all 5 pages unique?

                            • 11. Re: RouterForms Date Picker Calendar questions
                              gkaiseril MVP & Adobe Community Professional


                              Have the field names been changed?

                               

                              Field names with the same name share many common properties and value is one of them.

                               

                              If you need multiple copies of the same form in one PDF the recommended procedure is to create a hidden template and spawn the needed number of pages with the spawn setting set to rename the fields.

                               

                              A Lesson in Templates for Adobe Acrobat

                               

                              You might have problems with the calendar picker unless you add it after all the pages have been created and then add the feature.

                               

                              PDF Scripinog does not have the August 31 date issue present in form router's version.

                              • 12. Re: RouterForms Date Picker Calendar questions
                                Sean.twyman Level 1

                                I did try that hhowever on the copied pages, i will still need to change all the JavaScript calculation code foe all the fields

                                • 13. Re: RouterForms Date Picker Calendar questions
                                  gkaiseril MVP & Adobe Community Professional

                                  JavaScript is programming so you need to properly program the code to take the prefix of page number and template name into account in the JavaScript. It is even possible to have the focused field provide this data from its name.

                                   

                                  Have you looked at the event.target.name for a focused field?

                                   

                                  It will have "P[#].[termplatename].fieldnaje". One can use the split method to create an array of the level of the field name.

                                   

                                  Try this script in a field on a page generated by a template:

                                   

                                  var aName = event.target.name.split(".');

                                  console.show();

                                  console.clear();

                                  for(var I = 0; i < aName.length; i++) {

                                  console.println(i + ": " + aName[i]);

                                  }

                                   

                                  From this information one can compute various field names on the page.

                                  • 14. Re: RouterForms Date Picker Calendar questions
                                    Sean.twyman Level 1

                                    OK i understand what you are saying however all the field names changed in the new page, but the JavaScript in all those fields did not change to reflect the new field names.

                                     

                                    So im guess that is what your script does?

                                    Where exactly do i put it?

                                    • 15. Re: RouterForms Date Picker Calendar questions
                                      gkaiseril MVP & Adobe Community Professional

                                      The field names to change by page number, so your script needs to determine the "P#" level value and the name of the template that generated the page.


                                      My script shows how to get the name of the focused field and how to get the various hierarchical levels of the name from the name of the field. You can then use that information to create a string for the name of any field on that page.

                                       

                                      If one had a field called "total" that was the product of the fields "quantity" and "price" and the page for this calculation was spawned from a template named "invoice" the custom calculation script on the calculation tab for the field "total" could be:

                                       

                                      var FieldName = event.target.name; // name of the focused field;

                                      var aFieldName = FieldName.split(".");

                                      // aFieldName[0] is the P#;

                                      // aFieldName[1] is the template name "invoice";

                                      // compute only if the name of the template that spawned this field is "invoice"

                                      if(aFieldName[1] = "invoice") {

                                      event.value = this.getField(aFieldName[0] + "." + aFieldName[I] +"." + "price").value * this.getField(aFieldName[0] + "." + aFieldName[I] +"." + "quantity").value;

                                      }

                                       

                                      One can use this approach for any field that needs to access another field on the same page.

                                       

                                      A good script writer or programmer can actually create program code by using the scripting language.