I know this is probably easy but how to would I select only the first 3 digits from a form field called zipcode when I do #form.zipcode#
I would prefer this to be in cfml if possible.
Example 03954 becomes 039
This is for doing shipping calculations.
Thanks in advance.
Very easy, use the built-in left()
function.
Tags:
<cfset fullZipCode = trim(form.zipcode) />
<cfset firstThree = left(fullZipCode, 3) />
<cfdump var="#firstThree#" />
or in cfscript
<cfscript>
fullZipCode = trim(form.zipcode);
firstThree = left(fullZipCode, 3);
writeDump(var="#firstThree#");
</cfscript>
Docs: https://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-6e3a.html