Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loop over a delimited List and create an <cfoutput> as shown in the .Img

Posted on 2012-03-29
10
Medium Priority
?
225 Views
Last Modified: 2012-04-10
Hello experts,

I am need to Loop over a ; delimited List and create an <cfoutput> as shown in the .Img

Here is the List

Value ="Ketterer Stress Symptom Frequency Checklist; Symptom Checklist-90–Revised doi:10.1037/t01210-000 "

Please take a look at the img attached, need to create exact, also the numeric values in doi:10.1037/t01210-000 has to be a Hyper Link
DOI-test-and-measures.png
0
Comment
Question by:Dan Schimo
  • 5
  • 5
10 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 37783969
<cfloop index="aVal" list="#value#" delimiter=";">
   #aVal#<br>
</cfloop>
0
 

Author Comment

by:Dan Schimo
ID: 37784053
I am getting only the first record in the List

below is the Code I am using in the CFC, I am returning "thisLink" from the function.
also i need to put an href on the doi


<cfloop list="#arguments.record.Instrumentation#" index="thisTest" delimiters=";">
					
					<!---<cfset thisTestI = Trim(thisTest)>--->
					
					<cfsavecontent variable="thisLink">
					<cfoutput>
					<!---<span class="rdLinkItem"><a href="">#thisTestI#</a></span><br>--->
					#thisTest#<br>
					</cfoutput>
					<cfset result = result & trim(thisLink)>
				</cfsavecontent>
				
			</cfloop> 

Open in new window

0
 
LVL 39

Expert Comment

by:gdemaria
ID: 37784079
you're using "thisLink" inside your cfsavecontent before you're done creating it...


      <cfset result = result & trim(thisLink)>
   </cfsavecontent>
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
LVL 39

Expert Comment

by:gdemaria
ID: 37784096
perhaps something like this... doesn't seem like you need the cfsavecontent just to create a variable that you then contact with another.  Just build the entire thing inside the cfsavecontent


   <cfoutput>
   <cfsavecontent variable="result">
    <cfloop list="#arguments.record.Instrumentation#" index="thisTest" delimiters=";">
       <span class="rdLinkItem"><a href="">#thisTestI#</a></span><br>
       #thisTest#<br>
     </cfloop>
   </cfsavecontent>
  </cfoutput>
0
 

Author Comment

by:Dan Schimo
ID: 37784216
@gdemaria

Thanks for the catch , I put the cfset out side the cfsavecontent and now it is giving me the last record only,
0
 

Author Comment

by:Dan Schimo
ID: 37784605
i modified the code something like this which works ,and gives an output

output
 but separating the doi and putting an href around the numerical in doi:10.1037/t01210-000 is getting tough

 
 <cfsavecontent variable="result">
        <cfoutput>
        <table >
            <cfloop list="#(arguments.record.instrumentation)#" index="i" delimiters=";">
                <tr>
                    <td>#i#</td>
					<td><cfset i = replaceNoCase(i, "doi*", "<span class=""correctedTerm"">hello</span>","all" ) >
					<cfif len(i)><a href=>#i#</a></cfif></td>		
					                    
                </tr>
            </cfloop>
        </table>
        </cfoutput>
    </cfsavecontent>

Open in new window

0
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 37785012
I'm not clear on what the output should be...  if no doi, then no link?

Maybe you can tweak this...

 <cfsavecontent variable="result">
        <cfoutput>
        <table >
            <cfloop list="#(arguments.record.instrumentation)#" index="aVal" delimiters=";">
                <tr>
                    <td>#aVal#</td>
					<td>
                    <cfif aVal contains "doi:">
                      <cfset theLink = listLast(aVal,":")>
                      <a href="#theLink#">#theLink#</a>
                    <cfelse>
                      &nbsp; <!--- no doi, so no link ---->
                    </cfif>
                   </td>					                    
                </tr>
            </cfloop>
        </table>
        </cfoutput>
    </cfsavecontent>

Open in new window

0
 

Author Comment

by:Dan Schimo
ID: 37785242
This works well , I am getting and out put looks like

op
However , I would like to remove the text marked inside the Yellow box ref fig.

I tried all the trim functions but they need a pos to start
0
 

Author Comment

by:Dan Schimo
ID: 37785705
I have modified the code to suffice all the reqs, please let me know if there is any unforseen errors


<cfsavecontent variable="result">
        <cfoutput>
        <table >
             <cfloop list="#(arguments.record.instrumentation)#" index="aVal" delimiters=";">
                <tr>
				<cfif aVal contains "doi:">
					<cfset var PartDoi= aVal>
						<cfset  thisLink = listLast(aVal,":")>
						<cfset doi="doi:<a href=""#getLink(thisLink, baseURL)#"" target=""_blank"">#thisLink#</a>">
						<cfset PartDoi = Rereplace(PartDoi, Rereplace(doi,'<[^>]*>','','all'),'', 'all'  )>	
						<td>#PartDoi#</td>
							<td>#doi#</td>
					<cfelse>
					 <td>#aVal#</td>
					 <td>&nbsp;</td>
           	  	</cfif>		                    
                </tr>
            </cfloop>
        </table>
        </cfoutput>     
    </cfsavecontent>
	

Open in new window

thanks gdemaria
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 2000 total points
ID: 37786888
looks good!   The only thing is that you can't declare "var" anywhere except the top of your function, so this line should thrown an error..

<cfset var PartDoi= aVal>

just remove the var from this line and declare the variable at the top of your function to empty:

<cfset var PartDoi= "">
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question