tags:

views:

44

answers:

1

I have the following:

<dd>
    <select id="contactLocation" name="contactLocation" size="1">
        <option value="Online"<cfif attributes.contactLocation eq "Online">selected</cfif>>Online</option>
        <cfoutput query="storeLocations">
        <option value="#storeLocations.name#"<cfif attributes.contactLocation eq "#storeLocations.name#">selected</cfif>>#storeLocations.state# - #storeLocations.city#, #left(storeLocations.storeID, 3)#</option>
    </cfoutput>
    </select>

I added the two top cfset variables as I was trying to figure it out. The string in the database returns 111/NAME and I want to remove the forward slash and everything else to the right of it.

Currently with the two variables I added it just returns the first 3 characters but it is only displaying the one row for every single item in the drop down.

How do I remove the forward slash and everything to the right of it within #storeLocations.storeID#

UPDATE:

Actually Now I have it display all 3 characters per row but what if there are only 2 or if there are 4? I am close I just need the last part.

+6  A: 

If the separator is ALWAYS a "/" character and the "/" character will not appear in either token, think of this value as a list with a "/" delimiter and just get the last element with listLast:

listLast(storeLocations.storeID, "/")

If the 2nd part could have a "/" in it, but the first part never will, because its a number, then you can just get rid of the first token using listRest:

listRest(storeLocations.storeID, "/")

Edit: Since I can't tell my right from my left...

listFirst(storeLocations.storeID, "/")
Edward M Smith
The List functions are VERY powerful if one can think of a string as a list. Although in this case I think he wants ListFirst()
Al Everett
I needed the first part not the last part but I figured `listFirst` would work and it did! Thank you very much.
Bry4n
OH, my MILITARY right! Fixed!
Edward M Smith