scripter73
Programmer
Hi,
This isn't very hard, I just can't get my syntax together. Here's my goal - Split a string containing a space into two parts.
Example. Fullname = 'George Jetson'
I want Fname = 'George' and Lname = 'Jetson'.
Here's my code:
<html>
<head>
<title>Test String Looping</title>
</head>
<body>
<cfset string = "George Jetson">
<cfset fname="">
<cfloop from="1" to="#len(string)#" index="ThisChar">
<!--- <cfoutput>#Mid(string,ThisChar,1)#</cfoutput> --->
<!--- If the character is not blank, dump it in first name --->
<cfif #Mid(string,ThisChar,1)# eq ' '>
<!--- Variable Assignments Here --->
<cfoutput>#fname#</cfoutput>
<cfoutput>#lname#</cfoutput>
</cfif>
</cfloop>
</body>
</html>
Thanks in advance for your help.
scripter73
This isn't very hard, I just can't get my syntax together. Here's my goal - Split a string containing a space into two parts.
Example. Fullname = 'George Jetson'
I want Fname = 'George' and Lname = 'Jetson'.
Here's my code:
<html>
<head>
<title>Test String Looping</title>
</head>
<body>
<cfset string = "George Jetson">
<cfset fname="">
<cfloop from="1" to="#len(string)#" index="ThisChar">
<!--- <cfoutput>#Mid(string,ThisChar,1)#</cfoutput> --->
<!--- If the character is not blank, dump it in first name --->
<cfif #Mid(string,ThisChar,1)# eq ' '>
<!--- Variable Assignments Here --->
<cfoutput>#fname#</cfoutput>
<cfoutput>#lname#</cfoutput>
</cfif>
</cfloop>
</body>
</html>
Thanks in advance for your help.
scripter73