Solved

Select file with CFDIRECTORY

Posted on 2006-11-11
5
218 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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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