{"id":1574,"date":"2008-02-29T03:45:04","date_gmt":"2008-02-29T09:45:04","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/legacy\/?page_id=1574"},"modified":"2017-08-18T11:18:37","modified_gmt":"2017-08-18T16:18:37","slug":"how-to-use-field-substitutions-within-html-attributes-and-inline-styles","status":"publish","type":"page","link":"https:\/\/www.mrc-productivity.com\/legacy\/m-painter-app-prop\/how-to-use-field-substitutions-within-html-attributes-and-inline-styles","title":{"rendered":"Use Field Substitutions within HTML Attributes and Inline Styles"},"content":{"rendered":"<p><!-- Begin Content --><\/p>\n<h1>Use Field Substitutions within HTML Attributes and Inline Styles<\/h1>\n<p>&nbsp;<\/p>\n<p>m-Painter allows field substitution parameters within HTML attributes and CSS styles.  This document will help to explain how m-Painter can be used with field substitutions.<\/p>\n<p>Some HTML attributes accept any character data as valid; for example, title, alt, and class can be set to any text value.  Other HTML attributes, however, require values from a delimited list or range.  An example of this would be the attribute align, which for most elements accepts only the following values: left, center, right, justify.  Upon rendering the page, a field substitution may be rejected by m-Painter as invalid when used for these types of attributes.  However, many of these types of attributes have been deprecated in recent HTML specifications in favor of inline styles, and m-Painter will now correctly handle these substitutions in inline styles.<\/p>\n<p><strong>Example 1<\/strong><\/p>\n<p>Sometimes you may wish to conditionally set an attribute within the HTML based on the data in your dataset.  You may want to justify your data &quot;center&quot; or &quot;right&quot; depending on a value within the record.<\/p>\n<p><strong>Problem:<\/strong> m-Painter will reject the use of field substitutions when used with an attribute such an &quot;align&quot;:<\/p>\n<p><code>&lt; td align=\"${row.CALCULA001}\"&gt;${row.FLD1}&lt;\/td&gt;<\/code><\/p>\n<p>Because <code>${row.CALCULA001}<\/code> is not a valid value for the &quot;align&quot; attribute it is rejected and removed by m-Painter.<\/p>\n<p><strong>Solution:<\/strong> The appropriate way to accomplish this, which is now supported by m-Painter, is to use an inline style as follows:<\/p>\n<p><code>&lt;td style=\"text- align: ${row. CALCULA001}\"&gt;${row.FLD1}&lt;\/td&gt;<\/code><\/p>\n<p>m-Painter has now been enhanced to allow field substitutions with any style attribute.  A full list of properties and valid values for each can be found here: <a href=\"https:\/\/www.w3.org\/TR\/CSS21\/propidx.html\">https:\/\/www.w3.org\/TR\/CSS21\/propidx.html<\/a>.<\/p>\n<p><strong>Example 2<\/strong><\/p>\n<p>Suppose I have a report that displays various orders.  In this report I want to highlight the orders in which my customers ordered a quantity of 20 or more of a given product.  This is a situation where you can use a field substitution within an HTML inline style.<\/p>\n<ol>\n<li class=\"padleft\">Create a conditional calculation that will set the calc equal to the word &quot;Yellow&quot; if the quantity ordered is greater than or equal to 20.<\/li>\n<li class=\"padleft\">Compile the application.<\/li>\n<li class=\"padleft\">In m-Painter open the HTML source and find the field substitution for the field you wish to highlight.<\/li>\n<li class=\"padleft\">Add an inline style to the <code>&lt;td&gt;<\/code> tag associated with this field that sets the cell&#39;s background color equal to the calculation.<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"\/legacy\/images\/fieldsubs1.jpg\" \/><\/p>\n<p>The resulting output is below:<\/p>\n<p><img decoding=\"async\" src=\"\/legacy\/images\/fieldsubs2.jpg\" \/><\/p>\n<p><!-- End Content --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use Field Substitutions within HTML Attributes and Inline Styles &nbsp; m-Painter allows field substitution parameters within HTML attributes and CSS styles. This document will help to explain how m-Painter can be used with field substitutions. Some HTML attributes accept any character data as valid; for example, title, alt, and class can be set to any [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1410,"menu_order":20,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1574","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/comments?post=1574"}],"version-history":[{"count":9,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1574\/revisions"}],"predecessor-version":[{"id":8622,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1574\/revisions\/8622"}],"up":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1410"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/media?parent=1574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}