image: Gears IT Team - Processed HTML
General Utilities
logo: U of MN Extension


These dynamic modules provide some general use utilities.  For each module the HTML code to use is followed by a description of what the module does and some examples.  The names of the modules are Case Sensitive.  Be sure to use the right capitalization.

Each page that uses these modules must start with this include statement as one of the first lines of the HTML page.

<!--  #include virtual = "/include/gen_utils.inc"  -->


-


Global Variables

These are variables set to use as regular expressions in string matches or replacements.

/*  Regular Expressions  */
var Browsers = /Mozilla\/[234]/;
var Browser_IE = /MSIE/;
var DateDash = /\d\d?-\d\d?-\d\d\d?\d?/;
var DateSlash = /\d\d?\/\d\d?\/\d\d\d?\d?/;
var Digits = /[\d\.]+/;
var EndSpaces = / +$/;
var FindColon = /:/g;
var FindPlus = /\+/g;
var FindSlash = /\//g;
var FindSpace = / /g;
var FindTic = /'/g;
var FindQuote = /"/g;
var FindQuoteholder = /:':/g;
var ItemNumber = /[0-9]{4}/;
var Letters = /[A-Za-z]/;
var NonUserChars = /[^A-Za-z0-9\.-]/;
var NonTextChars = /[^\w \.-]/;
var NonEmailChars = /[^\w\.@-]/;
var TitleChars = /[^ \w\$\?\.\(\)%&-;:'",/]/;

var debug = 0;


-


General Functions

function FormatNumber(value, style, places, round_off, commas) {

FormatNumber(value, style, places, round_off, commas)
This function is used to evaluate the value passed in to a specific number of decimal places.  If an optional value is passed in for rounding, then any portion of the number that is cut will be rounded.  It returns a string representation of the number.  Live demo.

Parameters:
value - real, the number to be evaluated.   default - 0
style - integer, predefined styles.  default - 0
    0 - none
    1 - price $ xx,xxx.xx
    2 - percent x.xx %
places - integer, the number of decimal places in the returned number.   default - 2
round_off - boolean, should the number be rounded at the least significant digit?  Must be a value that will evaluate T/F.   default - 0 (false - no - truncate number)
commas - boolean, should the number be broken with commas at the orders of 10?  Must be a value that will evaluate T/F.   default - 0 (false - no)



OpenTable(width, spacing, padding, border)
This function is used to begin a table.  Generally paired with the CloseTable() function.

Parameters:
width - width of table in percent.   default - none
spacing - spacing between cells.   default - 3
padding - padding between cell contents and cell walls.   default - 5
border - width of table border in pixels.   default - 0



TableRow(prompt, value, col1_width, left_align, right_align)
This function is used to display information in a form that requires no input.

Parameters:
prompt - title for field (left column).   default - &nbsp;
value - information to display (right column).   default - &nbsp;
col1_width - size of left hand column in pixels or percent.   default - none
left_align - align value for lefthand column.   default - left
right_align - align value for righthand column.   default - left



CloseTable()
This function is used to end a table.  Generally paired with the OpenTable() function.

Parameters:  none



display_date(when, month_style, year_style, disp_day, disp_time)
This function is used to display the date and provide some control of display format.

Parameters:
when - the date to be displayed.   default - now
month_style - m - date as mm/dd/yyyy   default
M - date as Month dd, yyyy
year_style - y - year as two digit number (lowercase)
Y - year as four digit number (uppercase)   default
disp_day - if true then also display day of week at beginning.  Should be a value that will evaluate T/F.  only valid with month_style = M.   default - false
disp_time - if true then also display hh:mm.  Should be a value that will evaluate T/F.   default - false



img: gearsProcessed HTML opening page

iconInformation Technology Page

iconUniversity of Minnesota Extension Home Page

URL: http:// www3.extension.umn.edu/units/cets/it/processed/gen_utils.html  This page was updated Jan. 9, 2001 .
Online Privacy StatementContact Information.

University of Minnesota Extension is an equal opportunity educator and employer.
Copyright  ©  Regents of the University of Minnesota.  All rights reserved.