Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comma at the end of the list ! 2

Status
Not open for further replies.

lizok

Programmer
Jan 11, 2001
82
US
Hi. i am a newbie and i need your help. i have a query that extracts state name from the table. depending on the input, it can out put 1 state or a list of states:
Ak
or AK,OH,MD
the problem iam having is comma at the end of the list:
AK,OH,MD,
how can i get rid of comma at the end of the dynamically generated list?
please help
thank you
 
How did you create this list from your query? If you had used the ValueList, then the problem with the last comma wouldn't be there. Suppose you have a query called "GetStates" which extracts "State_name" from your DB. Create the list like this:

<cfset MyList=ValueList(GetStates.State_Name)>

However, if you want to stick to your own list (suit yourself ;-)...) try this:

<cfset MyList=Reverse(Replace(Reverse(MyList)),&quot;,&quot;,&quot;&quot;,&quot;ONE&quot;)>

Wow! :).
<webguru>iqof188</webguru>
 
Hi!

Here is a way to do it...

<CFLOOP QUERY=&quot;GetState&quot;>
[tab]<CFIF GetState.RecordCount EQ 1>
[tab][tab]<CFSET myList = &quot;#GetState.stateName#&quot;>
[tab]<CFELSE>
[tab][tab]<CFSET myList = myList &amp; &quot;,#GetState.stateName#&quot;>
[tab]</CFIF>
</CFLOOP>

I hope it solves your problem...
Ciao
Chris ;-)
 
Oups sorry iqof188 seems we were answering at the same time... :)

Chris...
 
Thank you very much for your help!
liz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top