webviewer_button ( )

Function stats

Average user rating
155
251
9999
Support
FileMaker 8.5 +
Date posted
04 March 2010
Last updated
06 March 2010
Version
Recursive function
No

Author Info
 El_Pablo

1 functions

Average Rating None

author_avatar



 

Function overview

Prototype

webviewer_button  ( content;   textCol;   bgCol )


Parameters

content  Content to display. Eg : Text


textCol  Text colour in CSS format. Eg : #ffeedd, abcdef or rgb(255,234,123);


bgCol  bgCol <-- Background colour. See textCol examples.


Description

Tags:  webviewer   layout calculation   dynamic calculation   button  

This function returns an HTML content formatted for a webviewer. I use it to create simple buttons with calculated content. This function can also be use to display calculation on a layout such as a current record index display.

Examples

Sample input

webviewer_button ("Test"; "#FFFFFF"; "RGB(0,0,255)")


Sample output

<html>
<head> <style> html, body { height: 100%; width: 100%; } body { margin : 0px 0px 0px 0px; border : 0px; } table { border-collapse: collapse; width : 100%; height : 100%; } td { text-align: center; vertical-align : center; font-family : "Arial"; font-size : 75%; color:#ffffff; background-color: #0000dd; } </style> </head> <body>
<table><tr><td>
$$companyName = tf b</td></tr></table>
</body>
</html>

 

Function code

/*
Name :
webviewer_button
Description :
This function returns an HTML content formatted for a webviewer. I use it to create simple buttons with calculated content. This function can also be use to display calculation on a layout such as a current record index display.

Syntax :
webviewer_button (content; textCol; bgCol)

Parameters :
content <-- Content to display. Eg : Text
textCol <-- Text colour in CSS format. Eg : #ffeedd, abcdef or rgb(255,234,123);
bgCol <-- Background colour. See textCol examples.

Examples :
webviewer_button ("Test"; "#000000"; "RGB(0,0,0)")
webviewer_button (Get (RecordNumber) & " of " & get (foundcount); ""; "")

Creator :
Nicolas Bourré 20100303
*/

Let (
[
ltc = Length (textCol);
tc = Substitute (Case (ltc = 6; "#" & textCol; ltc = 7; textCol; ltc = 0; "#000000"; textCol); " "; "");
lbc = Length (bgCol);
bc = Substitute (Case (lbc = 6; "#" & bgCol; lbc = 7; bgCol; lbc = 0; "#ffffff"; bgCol); " "; "")
];

"data:text/html,<html>¶
<head>
<style>

html, body {
height: 100%;
width: 100%;
}

body
{
margin : 0px 0px 0px 0px;
border : 0px;
}

table
{
border-collapse: collapse;
width : 100%;
height : 100%;
}

td {
text-align: center;
vertical-align : center;

font-family : \"Arial\";
font-size : 75%;

color:" & tc & ";
background-color: " & bc & ";
}
</style>
</head>
<body>¶
<table><tr><td>¶"
& content &
"</td></tr></table>¶
</body>¶
</html>"
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/251

    Prototype: webviewer_button( content; textCol; bgCol )
    Function Author: El_Pablo (http://www.fmfunctions.com/mid/155)
    Last updated: 06 March 2010
    Version: 1.1

*/
// ===================================

 

Comments

Daniele Raybaudi
05 March 2010



Hi

how about centering the text vertically ?

( also your example writes black on black )
  General comment
El_Pablo
06 March 2010



Hmmm... I'm not an HTML or CSS guru and it seems that the browser in FM doesn't like vertical positionning.

I'll correct the example typo, when I'll figure out how to center vertically the content in the webviewer.
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (28)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (13)
Filter  (12)
Layout Objects  (11)
Design  (10)
Array  (8)