Solved

ColdFusion Help displaying default value

Posted on 2012-03-17
6
300 Views
Last Modified: 2012-07-12
I'm searching a MySQL database using ColdFusion that has some empty fields within the database table. These empty fields display in an HTML table on the results page, as just being empty. What I'd like to do is to have the word "none" display if there is no value in the database for that field or column. In other words, I'd like to code my page to have the word "none" appear in place of those empty returns within my table.

Here is the search:
http://flashdesyne.com/wilsoncabinetry/search.cfm

Enter this model number: ET0444-O

Notice that the column for "Model Finish" is empty.

I'd like to have "none" appear in that column.

I tried cfparam with default as "none" but that didn't work.

Could someone please help me?

Thank you in advance.

elizabeth
0
Comment
Question by:Elizabeth2
6 Comments
 

Author Comment

by:Elizabeth2
ID: 37733476
Thanks to some previous posts, I figured this out using:

<cfif NOT Len(Trim(myqueryname.model_finish))>
<cfset myqueryname.model_finish = "none">
</cfif>
0
 
LVL 15

Accepted Solution

by:
Gurpreet Singh Randhawa earned 500 total points
ID: 37733548
good, u answered urself own

this way to

<cfif len(myqueryname.model_finish) IS 0>
None
</cfif>

No need to set and output it again

Cheers
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 37733554
This isn't correct..
<cfif NOT Len(Trim(myqueryname.model_finish))>
   <cfset myqueryname.model_finish = "none">
</cfif>

You cannot assign a value to a query column, although you could use the query set cell function.

<cfparam..> doesn't work because it does not test for empty, it tests for a non-existant variable...

Here's how you can do it..

In your select statement you can do this..

 select isNull(model_finihs,'none') as model_finish
       , ...
 from table...

Or when displaying you can use a CFIF statement..

<cfif Len(Trim(myqueryname.model_finish))>
   #myqueryname.model_finish#
<cfelse>
   none
</cfif>
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 7

Expert Comment

by:micropc1
ID: 37733793
You can do this in one line with IIF...

<cfoutput>
#IIF(LEN(TRIM(myqueryname.model_finish)), DE(myqueryname.model_finish), DE("none"))#
</cfoutput>

Open in new window

0
 
LVL 15

Expert Comment

by:Gurpreet Singh Randhawa
ID: 37734207
btw using IIF will effect Performance of the page, So i will not recommend it
0
 
LVL 7

Expert Comment

by:micropc1
ID: 37734699
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

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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