Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Ideal case
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Ideal case

 Post Reply Post Reply
Author
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Topic: Ideal case
    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.

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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 
   
Back to Top
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Posted: 21 November 2003 at 6:25pm
Goodness! The script is so long just for that. Anyway, thanks, Mart.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.