My.ADVISOR.com Sign-In
Username
Password
Sign Up 
Go to Article
Advanced Search 

FILEMAKER.PHP

Display FileMaker Pro Multi-Field Value Lists on the Web

Learn how to use the FileMaker API for PHP to build and display complex value lists

 DOWNLOAD (13,930 bytes) -- All the examples and supporting files referred to in this article.
By Jonathan Stark, Jonathan Stark Consulting

UNLOCKED -- This article is provided to subscribers of FILEMAKER ADVISOR or DATABASED ADVISOR or FILEMAKER ADVISOR. To subscribe or renew, go to Advisor Store.

One of the questions I hear the most is how to make FileMaker Pro's multi-field value lists show up on the Web. Multi-field value lists are based on table data and display values from a second field (figure 1). Developers frequently use this sort of value list when they want a user to select a record ID, but must present a list of human-readable options rather than the underlying IDs.

Figure 1: A limitation -- FileMaker.php doesn't have native support for multi-field value lists defined in FileMaker Pro.


Figure 2: Rendered code -- Browser pop-up menus look and act much like pop-up menus in FileMaker Pro.

In general, FileMaker.php does a great job of letting developers pull value lists through to the Web in a variety of simple and intuitive ways. However, this feature of FileMaker.php doesn't extend to multi-field value lists. If you pull a multi-field value list from FileMaker Pro using the API for PHP, you're only going to get the values from the first field selected in the "Specify Fields for Value List" dialog. If you want to display the values from the second field of the value list on the Web, you're going to have to do it on your own. Fortunately, it isn't too hard.


In this article, I'll show you how to build and display these sorts of multi-field value lists on the Web. Along the way, I'm going to spend a fair bit of time talking about writing the HTML code to build a pop-up menu, as well as some basic form-handling techniques.

All the examples and supporting files referred to in this article are available for subscriber download. It might help to grab those and refer to them while you read along.

Pop-up menus on the Web

Before digging into the FileMaker aspects of this issue, you have to be comfortable with the way pop-up menus work in HTML. A pop-up menu is an HTML form element made up of a set of OPTION tag pairs enclosed between open and close SELECT tags. Here's a snippet of HTML for a simple pop-up menu (see figure 2 for an example of how this code would render in a browser):

<select name="fruit">
  <option>Apple</option>
  <option>Banana</option>
  <option>Orange</option>
</select>

The name of the select block is "fruit" and there are three fruit options for users to pick from. Assuming this code is part of an HTML form and submitted with "Banana" selected, the server would receive a name/value pair:

fruit=Banana

Here's a more complex example:

<select name="fruit">
  <option value="1">Apple</option>
  <option value="2">Banana</option>
  <option value="3">Orange</option>
</select>

In this snippet, I've added value attributes to each option tag. When an option tag has a value specified, the value is sent to the server when the form is submitted, rather than the label that displays in the browser. In this case, if a user selects Banana from the pop-up menu and submits the form, the server would receive the following name/value pair:

fruit=2

There are a number of other attributes the SELECT and OPTION tags support, but the only other one you have to worry about is the SELECTED attribute of the OPTION tag. Unless instructed otherwise, a select block automatically selects (and therefore displays) its first option. In both preceding examples, the word "Apple" displays as the selected option when the Web page loads. As you'll see in the PHP examples that follow, there are times when it's desirable to have an option other than the first option selected when the page loads. Here's how:

<select name="fruit">
  <option value="1">Apple</option>
  <option value="2" selected="selected">Banana</option>
  <option value="3">Orange</option>
</select>

Now, when the select block loads in a browser, "Banana" appears as the default option. For more info about select and option tags, please refer to the sidebar about SELECT and OPTION tag syntax.

Display Multi-Field Value Lists on the Web

No reader comments ... yet.

    What do YOU think about this topic? Share your advice and thoughts using this form.

    Your Name

    REQUIRED : PUBLIC

    Your E-Mail

    REQUIRED : PRIVATE

    Job, Company

    OPTIONAL : PUBLIC

    City, State, Country

    OPTIONAL : PUBLIC

    Your Web Site

    OPTIONAL : PUBLIC

    Your Comment

    Please help everyone by keeping your comments on-topic, using clean language, and not defaming or making personal attacks.


    Your e-mail address is required, but it will not be displayed to the public or given to anyone. See our Privacy Policy. Comments become visible after they pass our spam filter, and spammers and abusers are permanently blocked. Please report spam or abuse.

    Jonathan StarkJonathan Stark is an author and instructor who specializes in FileMaker/PHP Web applications for creative professionals. Past clients include Staples, Turner Broadcasting, and Ambrosi (now Schawk). He has spoken at the FileMaker Developers Conference, has had numerous articles published in FileMaker Advisor and php|architect magazines, and is the author of the book Web Publishing with PHP and FileMaker 9 available from SAMS Publishing. Jonathan is reluctant to admit that he began his programming career more than 20 years ago on a Tandy TRS-80. http://jonathanstark.com

    Printer-friendly
    page layout

    Keyword Tags: FileMaker, FileMaker Development, FileMaker FileMaker Pro, PHP, PHP language, Web Development

    ADVISORAMA
    Q: How many babies does it take to screw in a lightbulb? A: What's a lightbulb?

    ARTICLE INFO

    FileMaker Advisor

    Web Edition: 2008 Week 12, Doc #19408

    Print Edition: April/May 2008, Page 8

    SUBSCRIBER ONLY ARTICLE LOCKED


    File: All the examples and supporting files referred to in this article.
    DOWNLOAD: 13,930 bytes

    Subscribe to FileMaker Advisor Magazine

    Read the advanced guide to creating custom business database solutions with FileMaker software. Subscribe now to gain access to all the archives and downloads.

    FileMaker.Advisor.com

    Subscribe to Advisor Basics of FileMaker Pro

    Learn the fundamentals of using FileMaker Pro software. Every issue gives you step-by-step instructions on creating the databases you need. Subscribe now!

    FileMaker.AdvisorBasics.com

    Secrets Of The Top Experts -- Now!

    See exactly how to do it, step-by-step, in Advisor Academy CDs created by the top experts. Click to see what you can learn right now.

    AdvisorAcademy.com

    Free E-Newsletters

    Keep up! Hot News, How-To, Tips & Tricks, Expert Advice, and more. Click to request your's free.

    AdvisorUpdate.info

    Need Know-How Now?

    What direction are you going with your business? Advisor Guides are packed with the answers you need to work smarter. Can you afford to fall behind?

    AdvisorStore.com

    Showcase Your Smarts

    Submit your tips, techniques and advice and let Advisor promote your business and build your career. Show the world what you know!

    AdvisorTips.com

    Use of this or any other site, content, product or service of Advisor Media constitutes acceptance of Terms of Use.
    Portions copyright ©1983-2008 Advisor Media, Inc. All Rights Reserved.
    Reuse or reproduction of any portion or quantity of Advisor Media's copyrighted content, in any form, for any purpose, requires written permission.
    ADVISOR®, the ADVISOR logo, and other names and logos that incorporate ADVISOR are registered trademarks, trademarks or service marks of Advisor Media, Inc. in the United States and/or other countries.
    Other trademarks are used for identification, editorial or descriptive purposes and are the property of their owners.
    stark013 posted 03/17/2008 modified 05/12/2008 03:44:47 AM ztfmfd/ztfmfd
    domino-144.advisor.com my.advisor.com 05/16/2008 02:51:34 PM