Solved

ColdFusion Help displaying default value

Posted on 2012-03-17
6
297 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

20 Experts available now in Live!

Get 1:1 Help Now