Custom Web Publishing Guide

Table Of Contents
Chapter 5
|
Developing FileMaker XSLT stylesheets 71
For example, suppose a field in a FileMaker database layout has the following checkbox options:
[ ] Red
[ ] Blue
[ ] Green
[ ] Small
[ ] Medium
[ ] Large
If a user selected Red only, then the field would contain the string “Red”. To determine whether the field
contains “
Blue”, you could use the following function call:
fmxslt:contains_checkbox_value(<field value node>,'Blue')
where <field value node> is the XPath to the <data> element for the checkbox field. The function would return
false” in this example.
A common application of this function is to display the checkbox value list in a web page and select the
checkboxes in the web page that are selected in the database. For example, the following HTML and XSLT
statements create a set of checkboxes for a field named
style using a value list named color_size:
<xsl:variable name="field-value" select="fmrs:field[@name='style']/fmrs:data" />
<xsl:for-each select="$valuelists[@NAME = 'color_size']/fml:VALUE">
<input type="checkbox">
<xsl:attribute name="name">style</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
<xsl:if test="fmxslt:contains_checkbox_value($field-value,.)">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input><xsl:value-of select="."/><br/>
</xsl:for-each>
The HTML and XSLT statements in the example would output the following checkboxes on a web page,
with
Red and Medium selected:
[x] Red
[ ] Blue
[ ] Green
[ ] Small
[x] Medium
[ ] Large