Print Page | Close Window

Ideal case

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7443
Printed Date: 30 March 2026 at 3:58pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Ideal case
Posted By: ngaisteve1
Subject: Ideal case
Date Posted: 21 November 2003 at 2:17am

My database's data is all uppercase, so use lcase() function to make it lower case but is there any function to make the first letter capital and keep the rest lowercase.

Eg

Steve instead of steve

Thanks.




Replies:
Posted By: KCWebMonkey
Date Posted: 21 November 2003 at 6:43am
Rather than store it in your database like that, why don't you keep all data in lowercase in the DB, and then format it with javascript when you want to display it?


Posted By: Mart
Date Posted: 21 November 2003 at 9:37am
if you search the usual places i.e. google maybe even this forum. You should find a ProperCase function. If i have time later i will post a link.


Posted By: Mart
Date Posted: 21 November 2003 at 9:57am

I got this code from planet source code btw.

[code]

function PCase(strInput)

    	'Variable declaration.
    	Dim strArr
    	Dim tmpWord
    	Dim tmpString
    	Dim last
    	
    	
    	'Create an array To store Each word In the String separately.
    	strArr = split(strInput," ")
    	
    	
    	if ubound(strArr) > 0 Then
    		For x = lbound(strArr) To ubound(strArr)
    			'Set Each word To lower Case initially.
    			strArr(x) = LCase(strArr(x))
    	
    			
    			'Skip the unimportant words.
    			Select Case strArr(x)
    				Case "a"
    				Case "an"
    				Case "and"
    				Case "but"
    				Case "by"
    				Case "for"
    				Case "in"
    				Case "into"
    				Case "is"
    				Case "of"
    				Case "off"
    				Case "on"
    				Case "onto"
    				Case "or"
    				Case "the"
    				Case "to"
    				Case "a.m."
    					strArr(x) = "A.M."
    				Case "p.m."
    					strArr(x) = "P.M."
    				Case "b.c."
    					strArr(x) = "B.C."
    				Case "a.d."
    					strArr(x) = "A.D."
    				Case Else
    				
    					'Capitalize the first letter, but don't forget To take into account that
    					'the String may be in Single or Double quotes.
    					if len(strArr(x)) > 1 Then
    						if mid(strArr(x),1,1) = "'" or mid(strArr(x),1,1) = """" Then
    							tmpWord = mid(strArr(x),1,1) & Ucase(mid(strArr(x),2,1)) & mid(strArr(x),3,len(strArr(x))-2)
    						Else
    							tmpWord = Ucase(mid(strArr(x),1,1)) & mid(strArr(x),2,len(strArr(x))-1)
    						End if
    						strArr(x) = tmpWord
    					End if
    					
    			End Select
    			
    			
    			'The unimportant words may need To be capitalized if they follow a dash, colon,
    			'semi-colon, Single quote or Double quote.
    			if x > 0 Then
    				if instr(strArr(x-1),"-") _
    				or instr(strArr(x-1),":") _
    				or instr(strArr(x-1),";") Then
    					tmpWord = Ucase(mid(strArr(x),1,1)) & mid(strArr(x),2,len(strArr(x))-1)
    					strArr(x) = tmpWord
    				End if
    			End if
    			
    		Next
    	Else
    		strArr(0) = LCase(strArr(0))
    	End if
    	
    	
    	'Make sure the first word In the array is upper case, but don't forget To take into account
    	'that the String may be in Single or Double quotes.
    	if mid(strArr(0),1,1) = "'" or 

         


Posted By: ngaisteve1
Date Posted: 21 November 2003 at 6:25pm
Goodness! The script is so long just for that. Anyway, thanks, Mart.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net