Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 464
  • Last Modified:

How to trun off display the CFCOL header in CFTABLE

Using CFTABLE below creates an empty line for each text file found with cfdirectory. I've been able to turn off the actual name but where the name should be is still a line feed, horribly screwing up my page, ending up with far too many empty lines on my page, and pushes my resulting #keywords# variable far down the page. I don't need the attributes of cfdirectory or cftable.

 How can I turn off the hidden "NAME" display of CFTABLE and therefore the blank line feeds?

 - Georgia

<CFDIRECTORY DIRECTORY="c:\keywords" NAME="myDirectory" filter="*.txt">
<CFTABLE QUERY="myDirectory">
   <CFCOL HEADER="NAME:" TEXT="">
</CFTABLE>

<form name="form1" method="post" action="">
   <select name="Filename">
      <option value=""><cfoutput>#FileName#</cfoutput></option>
      <cfloop query = "mydirectory">
         <cfoutput>
            <option value="#mydirectory.name#">#mydirectory.name#</option>
         </cfoutput>
      </cfloop>
   </select>
   <input type="submit" name="SubmitButton" value="submit">
</form>
<cfoutput>
   <cffile action="read" file="c:\keywords\#Filename# " variable="keywords">
</cfoutput>
<cfif IsDefined("SubmitButton")>
   <cfoutput>#keywords#</cfoutput>
</cfif>

I've been able to workaround this by using a DIV statement and an absolute page setting with CSS, but would rather solve the actual problem, if possible.
0
RollinNow
Asked:
RollinNow
  • 4
  • 4
  • 2
2 Solutions
 
aseusaincCommented:
Could always just build the table manually.

<cftable>
<cfoutput query="myDirectory">
<tr>
<td>#somevariable#</td>
<td>#anothervariable</td>
<td>#somethingelse#</td>
</tr>
</cfoutput>
</table>
0
 
gdemariaCommented:

 Hi Georgia,

 What is the purpose of your CFTABLE in the code above?   The reason I ask is because it doesn't appear you're trying to show any data in the CFTABLE, but just put in the column heading "NAME:"

Please check out this code, I'm trying to guess your intent and see if its helps ...


This looks like the submit part, let's move it to the top and put the CFFILE read into the CFIF so its only called when submitted...

<cfif IsDefined("SubmitButton")>
    <cffile action="read" file="c:\keywords\#form.Filename# " variable="keywords">
    <cfoutput>#cffile.keywords#</cfoutput>  
</cfif>


<form name="form1" method="post">   <!---- no action, form will post to same page ---->
 <table>
   <tr>
    <td>NAME: </td>  <!----- here is the column heading for the select box ----->
    <td>
   <select name="Filename">
      <option value="" selected>- Select a File -      <!----- Note the change here, is this what you wanted here? ----->
      <cfloop query = "mydirectory">
         <cfoutput>
            <option value="#mydirectory.name#">#mydirectory.name#</option>
         </cfoutput>
      </cfloop>
   </select>
    </td>
    </tr>
    <tr>
      <td colspan="2" align="center">
        <input type="submit" name="SubmitButton" value="submit">
      </td>
    </tr>
</table>
</form>

0
 
RollinNowAuthor Commented:
Aseusainc,

Not sure what to make of your suggestion. It seems there needs to be at least one CFCOL defined so that doesn't seem to work.

 - Georgia
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
RollinNowAuthor Commented:
Gdemaria,

> What is the purpose of your CFTABLE

So I can have a query output for mydirectory: <cfloop query = "mydirectory">

I had to use CFDIRECTORY to get the  list of files  and someway to loop through it. I didn't know how to loop through an index or so found that  code somewhere on EE.

Everything is working, it's just that the CFTABLE is used to set the cfloop query but it requires the table output and I don't see a way to turn it off.

Your code is the same result as what I have. I need something which does the same but either does not use cftable or can turn off the CFCOL output. I deleted the NAME which before looked like this:

<CFCOL HEADER="NAME:" TEXT="NAME">

Now at least it does not display the name, but does do the line feeds where a file in the directory was found. That's the problem. Am I making sense?

  - Georgia




0
 
gdemariaCommented:

 Hi Georgia,

 So, you would like to show all the files above your select list...

 The directory is..

   My Word Document.doc
   My Excel Document.xls
   A text file.tx

  Please choose a file:
  [ - select a file -    v ]     <--- that's a select box :)


 If so, something like this perhaps?

<table>
<cfoutput query = "mydirectory">
  <tr>
    <td>#myDirectory.filename#</td>
  </tr>
 </cfoutput>
 </table>


 If I'm not barking up the right tree, let me know what you want it to look like ...

 Cheers,
0
 
aseusaincCommented:
Georgia,

Gdemaria's explaination is basically the same as I was getting at.  Added a decription row for clarity:

<table>
  <tr>
    <td>Filename</td>
  </tr>
<cfoutput query = "mydirectory">
  <tr>
    <td>#myDirectory.filename#</td>
  </tr>
 </cfoutput>
 </table>
0
 
RollinNowAuthor Commented:
It was my understanding that a cfoutput query requires that a query be defined. There is none. So how can I use either of your examples? It makes no sense to me.

I gave you all the code I'm using. The only time a query was set is with this line:

<CFTABLE QUERY="myDirectory">

I had never been familar with it until I ran over it here on EE and still am not sure how it works or why. But it seems obvious to me that it is the problem, other than my lack of experience and knowledge.

The trouble has to be me, but so far, I don't have a clue as to how either of you are getting to your suggestions and the examples certainly do not work, not with what you have shown so far.  Please take a look at the code I am using. There is nothing else, not query defined other than the cftable, if in fact, that is a defined query.

If this is not clear, then we cannot continue unless someone can help making it clear.  Query. That's the key. How is it defined, and how do I use it, in the code I have at the top of this page, and how to I use the cftable to, well, I've already stated this so there's no  reason to waste your time going over it again. I already have a workaround and I asked this question only to discover the answer, to learn something. Honest. But  nothing, absolutely nothing either of you have suggested makes any sense to me at all.

 - Georgia


0
 
gdemariaCommented:

 The result of CFdirectory using the "list" action is a query.

 <CFDIRECTORY DIRECTORY="c:\keywords" NAME="myDirectory" filter="*.txt">
                                                                            ^^^^^^ this is the name of the query

When using the action = "list", cfdirectory returns five result columns you can reference in your cfoutput:

name   - Directory entry name.
size   -  Size of directory entry.
type    -  File type: File for File or Dir for Directory.
dateLastModified  -  Date an entry was last modified.
attributes   -   File attributes, if applicable.
mode   -  (For UNIX and Linux only)

You can use the following result columns in standard CFML expressions, preceding the result column name with the query name:

<cfoutput query="mydirectory">
#mydirectory.name#
#mydirectory.size#
#mydirectory.type#
#mydirectory.dateLastModified#
#mydirectory.attributes#
</cfquery>



 
0
 
gdemariaCommented:

>  The only time a query was set is with this line:

 <CFTABLE QUERY="myDirectory">


 The CFtable tag takes an existing query and turns it into a table, outputting the query's columns in the rows and cells of the table.  

<cftable query = "myDirectory"  colSpacing = "3" HTMLTable>
   <cfcol header = "<B>File Name</B>"   align = "Left"  width = 2   text  = "#myDirectory.name#">
</cftable>

 This is the same as doing...

<table>
  <tr>
    <td>Filename</td>
  </tr>
 <cfoutput query = "mydirectory">
  <tr>
    <td>#myDirectory.filename#</td>
  </tr>
 </cfoutput>
 </table>

aseusainc  and I prefer doing this second example over using CFTABLE because we like the control and its easier (in our opinion) to use and control (agreed, aseusainc?)


 So, therefore your initial code...

<CFTABLE QUERY="myDirectory">
   <CFCOL HEADER="NAME:" TEXT="">
</CFTABLE>

 Doesn't really make sense because you don't have any value in the TEXT="" field, you are just displaying an empty cell for every row of the query="mydirectory"

 The above command results in this...

<table>
  <tr>
    <td>NAME: </td>
  </tr>
  <tr>
    <td></td>  <!---- one empty row shown for each file returned in the CFDIRECTORY query ---->
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
 </table>

 
 That is why we were guiding you towards using this:

<table>
  <tr>
    <td>Filename</td>
  </tr>
<cfoutput query = "mydirectory">
  <tr>
    <td>#myDirectory.filename#</td>
  </tr>
 </cfoutput>
 </table>

 That will show the Filename heading and one row for each file in the directory.

 However, if you don't want to show all the files in the directory as I said on 1/12/2006 09:09PM EST

 The directory is..

   My Word Document.doc
   My Excel Document.xls
   A text file.tx

  Please choose a file:
  [ - select a file -    v ]     <--- that's a select box :)


 Then just completely remove this command

<CFTABLE QUERY="myDirectory">
   <CFCOL HEADER="NAME:" TEXT="">
</CFTABLE>

 from your code, its really doing nothing at all, except showing the NAME: .



 If your goal IS to show the word NAME: next to the SELECT box, then refer to my comment above...  this will do it..


<form name="form1" method="post">   <!---- no action, form will post to same page ---->
 <table>
   <tr>
    <td>NAME: </td>  <!----- here is the column heading for the select box ----->
    <td>
   <select name="Filename">
      <option value="" selected>- Select a File -      <!----- Note the change here, is this what you wanted here? ----->
      <cfloop query = "mydirectory">
         <cfoutput>
            <option value="#mydirectory.name#">#mydirectory.name#</option>
         </cfoutput>
      </cfloop>
   </select>
    </td>
    </tr>
    <tr>
      <td colspan="2" align="center">
        <input type="submit" name="SubmitButton" value="submit">
      </td>
    </tr>
</table>
</form>


 So to directly answer this question:

>> How can I turn off the hidden "NAME" display of CFTABLE and therefore the blank line feeds?
                                      ^^^^  hidden??

 The answer is completely remove this command

<CFTABLE QUERY="myDirectory">
   <CFCOL HEADER="NAME:" TEXT="">
</CFTABLE>


 Hope that helps clear it up.  
0
 
RollinNowAuthor Commented:
That through me for a bit:

<cfoutput query="mydirectory"> </cfquery>

You meant <cfoutput query="mydirectory"> </cfoutput>

I don't need the cftable at all, nor do I need the cfoutput query. So, I just deleted the cftable code completely and left the rest of the code and it works as I want. Click. Finally. Hit me over the head next time!

I wish I had tried that first.  Thanks for the help from you both, and the instruction. Now I have to prepare for another storm here in Oregon. The last one knocked out our power for nearly two days.

 - Georgia


0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now