我有以下内容:
<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>
Run Code Online (Sandbox Code Playgroud)
我添加了两个顶级cfset变量,因为我试图找出它.数据库中的字符串返回111/NAME,我想删除正斜杠和其右边的所有其他内容.
目前我添加了两个变量,它只返回前3个字符,但它只显示下拉列表中每个项目的一行.
如何删除正斜杠及其右侧的所有内容 #storeLocations.storeID#
更新:
实际上我现在每行显示3个字符,但如果只有2个或者有4个字符怎么办?我很接近我只需要最后一部分.
如果分隔符始终为"/"字符且"/"字符不会出现在任一标记中,请将此值视为带有"/"分隔符的列表,并使用listLast获取最后一个元素:
listLast(storeLocations.storeID, "/")
Run Code Online (Sandbox Code Playgroud)
如果第二部分中有一个"/",但第一部分永远不会,因为它是一个数字,那么你可以使用listRest摆脱第一个令牌:
listRest(storeLocations.storeID, "/")
Run Code Online (Sandbox Code Playgroud)
编辑:因为我无法从左边告诉我的权利......
listFirst(storeLocations.storeID, "/")
Run Code Online (Sandbox Code Playgroud)