[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 136
  • Last Modified:

String Manupulation.

i have a variable #first_name# , which sometimes have content like "John F." and also "John". I need to extract First name and middle initial into different variables. How do I do that? Also I need to know how to manupulate CFSWITCH statement.  I need to assign codes for US states (AL->01, AR->02,CA->23,etc...)

Thanks!
0
anusha
Asked:
anusha
  • 3
  • 2
1 Solution
 
nathansCommented:



Variable First Name
==============================

<html>
<head>
      <title>Sample on How to get First Name and Middle Initial</title>
</head>
<body bgcolor="ffffff">

<cfset First_Name = "Nathan A">
<cfset First_Name1 = "Nathan">

<CFSET FirstName = #GetToken("#first_name#", 1," ")#>
<CFSET MI = #GetToken("#first_name#", 2," ")#>
<CFSET FirstName1 = #GetToken("#first_name1#", 1," ")#>
<CFSET MI1 = #GetToken("#first_name1#", 2," ")#>
<br>
0<br>
====<br>
<cfoutput>#FirstName# #MI#</cfoutput><br>
1<br>
====<br>
<cfoutput>#FirstName1# #M1I#</cfoutput>
</body>
</html>






CFSWITCH
==============================

<cfswitch expression="#STATE#">

      <cfcase value="01">
  AL
      </cfcase>
      <cfcase value="02">
      AR
      </cfcase>
      <cfcase value="23">
      CA
      </cfcase>

</cfswitch>
0
 
nathansCommented:
Copy the small file for figuring out how to do the first_name and save in as a file then browse it and it will show you that it works.

on cfswitch the code for each state goes in place of the two-digit name.
0
 
anushaAuthor Commented:
Thanks Nathans :-)

Anusha
0
 
nathansCommented:
Your Welcome isn't ColdFusion Awesome.

I love it.


I work in the DFW Area in case someone is hiring.

Nathan@nsnd.com
0
 
anushaAuthor Commented:
Nathans,

since cfswitch does not work inside cfoutput tags , how would I do cfswitch in the middle of query?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now