Solved

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

Posted on 2012-03-29
10
217 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

14 Experts available now in Live!

Get 1:1 Help Now