Jump to content

Escaping Comma


vchris

Recommended Posts

I have a list and one of my list entries has a comma. How do I escape a comma in a list?Example of the entry:<cfset sectorList = ListAppend(sectorList, "iron,_steel_and_limenite_smelting") />

Link to comment
Share on other sites

<cfset sectorList = ListAppend(sectorList, "iron#chr(44)#_steel_and_limenite_smelting") />

That should do it.Use this code to get the numeric value of the chr() function you are looking for:

<cfloop index="x" from="1" to="50"><cfoutput>#x# = #Chr(x)#<br /></cfoutput></cfloop>

Increase the "to" value here to something like 5000 or 50000 to get even more characters.:)

Link to comment
Share on other sites

As I think about it more, that might not work either . . . I'd have to look into this a little more if it doesn't.Are you able to replace it with some other value that you could then translate whenever this information is retrieved again?

Link to comment
Share on other sites

Yeah I just tried it out and it doesn't work. See for yourself:<cfset myList = "john#chr(44)# test" /><cfloop index="i" list="#myList#"> <cfoutput>#i#</cfoutput></cfloop>Could I change the default delimiter to something else?EDIT:I got it! I replaced the default delimiter by a !. It works perfectly.

Link to comment
Share on other sites

oh oh got another problem.See I have this drop down that is populated with this coldfusion list I created. Then when a selection is made a list of links appears underneath the drop down that the user can click on to go view a certain document.So I have:<cfset sectorList = ListAppend(sectorList, "iron,_steel_and_limenite_smelting","!") /><cfset iron,_steel_and_limenite_smelting = '<a href="##">link 1</a>,<a href="##">link 2</a>' />but the comma is not accepted in a variable name. Basically I have the drop down option value equal to the coldfusion variable. All the option in my drop down have a list of their own links. I'm not sure if this is the best way to do this but I thought it was simpler than arrays and easier to update. If you have a better way of doing this let me know.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...