Solved

Select file with CFDIRECTORY

Posted on 2006-11-11
5
220 Views
Last Modified: 2013-12-24
I want to select a text file from list of files in a directory and use that file name for a variable.

My resultant selection box is either empty or I get an error trying to use a variable.  I guess I don't know how to set the variable name for the cfoop code so that the list displays or I don't know how to use cfdirectory, or both, or I need to take up Needle-point instead.


<CFDIRECTORY DIRECTORY="c:\server\default\keywords"
    NAME="myDirectory"
    SORT="name ASC, size DESC"
Action ="list"
filter="*.txt">
<CFTABLE QUERY="myDirectory">
    <CFCOL HEADER="NAME:"
            TEXT="#Name#">
    <CFCOL HEADER="SIZE:"
            TEXT="#Size#">
</CFTABLE>

   
<select NAME="GetKeyList">
     <CFLOOP index="i" FROM="1" TO="#ListLen(Name)#">
          <option><cfoutput>#listgetat(Name,i)#</cfoutput></option>
     </CFLOOP>
</SELECT>
How can I display a list of files in the directory, so I can then select one from the list to create a variable using the filename of the text file selected?

 -   Georgia
0
Comment
Question by:RollinNow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 17923362
<cfoutput>#mydirectory.name#</cfoutput>
0
 

Author Comment

by:RollinNow
ID: 17923507
Thanks. That's closer to working but my index TO is wrong. What do I use for the:

 FROM="1" TO="#ListLen(unknown)#">

Here's the loop:

<select name="GetKeyList">
     <cfloop index="i" FROM="1" TO="#ListLen(unknown)#">
          <option><cfoutput>#mydirectory.name#</cfoutput></option>
     </cfloop >
</select >

I don't need cfdirectory to list the names, just offer them in my selection drop-down list so I can select. As it is now, only one filename is avaiable, so what do I use for the unknown in <cfloop index="i" FROM="1" TO="#ListLen(unknown)#">

 - Georgia

0
 
LVL 21

Accepted Solution

by:
pinaldave earned 300 total points
ID: 17923578
Hello,
you should not use index.

You should do as follows:
 <cfloop query="mydirectory">
          <option><cfoutput>#mydirectory.name#</cfoutput></option>
     </cfloop >

That will do the job.
Regards,
---Pinal
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 200 total points
ID: 17923966

 Aren't you guys are forgetting the value parameter in option?


 <select name="GetKeyList">
      <cfoutput query="mydirectory">
          <option value="#mydirectory.name#"> #mydirectory.name#
     </cfoutput>
 </select >
0
 

Author Comment

by:RollinNow
ID: 17924070
Thanks pinaldave for the fix, and thanks so much to gdemaria for reminding me of SELECT. I was wondering why the form was blank!  You've got a share for your help.

  Thanks to both of you,

  - Georgia


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

728 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