Solved

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

Posted on 2012-03-29
10
216 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 500 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 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now