Good day all,
well i have been searching the web and i cannot find an answer to my question. First off i dont know if i should post this here or in the Javascript section because i am a coldfusion user and didnt know if javascript does this. Second my problem is i want to add a "." after the 3rd character or letter. Ex.

var str = "0222232"
This is where the function would come in to add a . after the 3rd number. So the output would be 022.2232

Is this possible? I normally show code, but i wouldnt even know where to start. Thanks for the help.

i dont know about coldfusion but you should be able to do something like this
substring(0,3) + "." + substring(4,stringLength)
or if you can use it like a numeric value then just multiply by 1000

Thanks divin757,
Your code helped get me started, but then i noticed that it didnt output the whole thing to include the period. So i just changed the value of 4 to 3 and added str to the substrings and length.

var str = "0222232";
document.write(str.substring(0,3) + "." + str.substring(3, str.length))

Again thanks alot.

I guess i should post what i use now, for others to view.

<cffunction name="convert" access="public" returntype="string">
    <cfargument name="latitude" required="yes" type="any">
    <cfargument name="longitude" required="yes" type="any">
    <cfset var lat = "">
    <cfset var long = "">
    <cfset lat = #replace(ARGUMENTS.latitude,".","")#>
    <cfset long = #replace(ARGUMENTS.longitude,".","")#>
    <cfset lat.substring(2,4)&"."&lat.substring(4,len(lat))>
    <cfset long.substring(1,3)&"."&long.substring(3,len(long))>
    <cfset coord = lat&","& long>
    <cfreturn coord>
</cffunction>
<cfoutput>#convert("E12345.678","N1234.567")#</cfoutput>

I am not aware with coldfusion although i am in learning process and your tip is helpful for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.