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

x
?
Solved

Select file with CFDIRECTORY

Posted on 2006-11-11
5
Medium Priority
?
225 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
  • 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 1200 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 800 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

972 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