11 Replies Latest reply on Sep 27, 2011 9:28 PM by kmmikule

    formatting text labels and/or fields through script

    kmmikule

      Title

      formatting text labels and/or fields through script

      Post

      Hi,

       

      I am working on my first web-compatible database, and realized that conditional formatting does not show up on a web-based system (please correct me if I am wrong!). I was hoping someone could explain how to change the font color of a text label.

      So pretty much, I have a form for users to fill out. If the users miss some essential fields, I just want to highlight them red so they can see what they missed. I have a bunch of fields with corresponding labels (eg. name, phone number, email, etc). So I would be happy if either I could turn the text label red or highlight the background color of the field or some other approach. I am really not picky about exactly how this will work--whatever is easiest actually.

      This is a trivial process with conditional formatting, but again, I have to do this through a script so that it is web compatible. In the script commands, I saw instructions to change color/style of text, but I was unable to get results. An example of how this would be used (if indeed this is the correct approach) would be greatly appreciated.

       

      Thanks very much for your time!



        • 1. Re: formatting text labels and/or fields through script
          philmodjunk

          Before we could use conditional formatting, we sometimes used a container field filled with a colored rectangle and placed behind a transparent field to highlight it. You can use either a realtionship or a calculation to control whether or not the color appears to highlight the field.

          Here's a calculation approach you could use:

          Define a global container field and insert or paste a colored rectangle into it. The exact size and proportions are not crucial as long as you don't use something so small that it's only one or two pixels large.

          Define a calculation field with an If function like this:

          If ( BooleanExpression ; GlobalcontainerField )

          Be sure to select "container" in the return type drop down for this field.

          In place of "Booleanexpression" put whatever calculation you want just like you would for your conditional format. If it is true, the contents of the globalContainer field are returned and this calculation field can be used to "highlight" the field in front of it. If the expression is false, the field will be empty and the layout's background will show through, leaving the field unhighlighted.

          • 2. Re: formatting text labels and/or fields through script
            kmmikule

            Thanks very much for the quick reply!

            I have not worked much with containers, and am wondering how to paste in a rectangle? I don't actually have a representation of it on any layouts.

            • 3. Re: formatting text labels and/or fields through script
              philmodjunk

              Put your container field with global storage on a layout somwheres. Enter layout mode. Use the rectangle tool to create one of the color you want. Copy it to the clipboard. Return to browse mode. Click into the this field and paste the copied rectangle.

              WHen you place the calculation field that refers to this container field on your layout, use data formatting to specify 'enlarge or reduce image to fit' and clear the "maintain original proportions" check box. This way, your rectangle will expand out the full height and width of your field.

              • 4. Re: formatting text labels and/or fields through script
                kmmikule

                Thanks! Your instructions were very clear and I got container and calculation fields. And I am getting partial results. Here, I have included two screenshots--one of what I see in Filemaker (first image) and one of what I see on the website where the system is running (second image):

                Shows correct results from Filemaker

                 

                Incorrect results from website

                The results on the Filemaker image are correct (the three areas highlighted are being tested for empty fields). They are correctly detected as incomplete.

                On the website version however, the birth date and phone number fields are not highlighted.

                Any thoughts?

                • 5. Re: formatting text labels and/or fields through script
                  philmodjunk

                  Notice that the fields are not transparent when viewed from the web browser. If the calculation field is the same size as the field it is behind, it will be hidden from view when veiwed from this browser. This is a bit disappointing. I had hoped that fields specified as transparent in Filemaker would also be transparent in IWP. You may need to make the "Highlight" field several pixels taller and wider so that they are outlined in read at least when their calculations evaluate as true.

                  • 6. Re: formatting text labels and/or fields through script
                    kmmikule

                    I thought that this might be the trouble as well, but it does not seem to have any effect. I made the highlight cover half the screen just so that I could see if it was showing up, but it behaves in exactly the same way (only the third of the three highlights appears).

                    • 7. Re: formatting text labels and/or fields through script
                      philmodjunk

                      Is this three copies of the same calculation field or three different calculation fields?

                      What is the exact calculation that you used? (can't imagine a calculation here that would evaluate differently in IWP, but let's chack and be sure...)

                      • 8. Re: formatting text labels and/or fields through script
                        kmmikule

                        Okay, so I am using three different containers and three different calculations.

                        The containers are addressContainer, birthdayContainer, and phoneContainer. The associated calculations are addressCalculation, birthdayCalculation, and phoneCalculation. The original fields are simply called street, city, birthyear, phone, etc.

                        My calculations are the following:

                        (for phone) If ( IsEmpty ( phone ); phoneContainer )

                        (for address) If ( IsEmpty ( street ) or IsEmpty ( city ) or IsEmpty ( country ) or IsEmpty ( postal ); addressContainer )

                         

                        All of my containers are global, as you suggested they should be.

                        • 9. Re: formatting text labels and/or fields through script
                          philmodjunk

                          You only need one container field referenced by all three calculation fields if the highlight color is to be the same in all three cases.

                          Of course, that doesn't explain why two of the three calculation fields do not evaluate correctly in IWP.

                          Is the "do not evaluate if all referenced fields are empty" check box selected or cleared in each of these calculations?

                          • 10. Re: formatting text labels and/or fields through script
                            kmmikule

                            Thanks for the tip about containers!

                            The check box is cleared in all cases.

                            I will be away from my computer for about an hour. I really appreciate all of your help so far and for the prompt responses!

                            • 11. Re: formatting text labels and/or fields through script
                              kmmikule

                              So I made only one container (rather than three as I had before). Now, all three highlights show up in Filemaker, and none show up on the website (not even the one I saw before)!

                              Another odd behavior that is arising: every time I quit Filemaker and restart it, the container that I created to contain my highlighting is empty.

                              I would greatly appreciate any more suggestions or tips on how to approach this!