cJustify

Description

Centers a string in a field length.

Categories

Related

Syntax

Cjustify(string, length)

Attributes

AttributeDescriptionRequiredDefault
lengthA positive integer or a variable that contains one. Length of field. Can be coded as: A number; for example, 6 A string representation of a number; for example, "6" Any other value causes ColdFusion to throw an error.
stringA string or a variable that contains one. May be empty. If it is a variable that is defined as a number, the function processes it as a string.

Returns

String, center-justified by adding spaces before or after the input parameter. If length is less than the length of the input parameter string, the string is returned unchanged.

Example

<!--- This example shows how to use CJustify. ---> 
<CFPARAM name = "jstring" DEFAULT = ""> 
 
<cfif IsDefined("FORM.submit")> 
<cfdump var="#Form#">  
    <cfset jstring = Cjustify("#FORM.justifyString#", 35)> 
</cfif> 
<html> 
<head> 
<title>CJustify Example</title> 
</head> 
<body> 
<h3>CJustify</h3> 
Enter a string; it will be center-justified within the sample field. 
<form action = "cjustify.cfm" method="post"> 
<input type = "Text" value = "<cfoutput>#jString#</cfoutput>"  
        size = 35 name = "justifyString"> 
<input type = "Submit" name = "submit">  
<input type = "RESET"> 
</form> 
</body> 
</html>