Skip to main content
Known Participant
April 29, 2014
Answered

How can i make it work around if a column is NULL?

  • April 29, 2014
  • 1 reply
  • 429 views

I have a table that display some question,

But some may have 4 or 5 question.

Here is my code.

          <cfloop index="i" from="1" to="5">

                 <cfset question = GetEmployeeCSEDepts["csedept_question" & i][GetEmployeeCSEDepts.CurrentRow]>

                       <tr>

                           <td valign="top">

                                  <select name="sltRating#i#" size="1">

                                         <option value="">-- Select Rating --</option>

                                          <option value="5">Exceptional</option>

                                            <option value="4">Exceeds Standards</option>

                                             <option value="3">Successful</option>

                                             <option value="2">Needs Improvement</option>

                                             <option value="1">Unsatisfactory</option>

                                             <option value="0">N/A</option>

                                     </select>

                                  </td>

                         <td valign="top">#question#</td>

                              </tr>

                </cfloop>

So rigth now it display all the quesions but it even questio5 is null.

How will I be able to make it work around to display if csedept_question is NULL to not show

to the user?

This topic has been closed for replies.
Correct answer EddieLotter

If I understand you correctly, this should work:

          <cfloop index="i" from="1" to="5">
                 <cfset question = GetEmployeeCSEDepts[
"csedept_question" & i][GetEmployeeCSEDepts.CurrentRow]>

                   <cfif question neq "">
                       <tr>
                           <td valign=
"top">
                                  <select name=
"sltRating#i#" size="1">
                                         <option value=
"">-- Select Rating --</option>
                                          <option value=
"5">Exceptional</option>
                                            <option value=
"4">Exceeds Standards</option>
                                             <option value=
"3">Successful</option>
                                             <option value=
"2">Needs Improvement</option>
                                             <option value=
"1">Unsatisfactory</option>
                                             <option value=
"0">N/A</option>
                                     </select>
                                  </td>
                         <td valign=
"top">#question#</td>

                     </tr>

                  </cfif>

                </cfloop>

1 reply

EddieLotter
EddieLotterCorrect answer
Inspiring
April 29, 2014

If I understand you correctly, this should work:

          <cfloop index="i" from="1" to="5">
                 <cfset question = GetEmployeeCSEDepts[
"csedept_question" & i][GetEmployeeCSEDepts.CurrentRow]>

                   <cfif question neq "">
                       <tr>
                           <td valign=
"top">
                                  <select name=
"sltRating#i#" size="1">
                                         <option value=
"">-- Select Rating --</option>
                                          <option value=
"5">Exceptional</option>
                                            <option value=
"4">Exceeds Standards</option>
                                             <option value=
"3">Successful</option>
                                             <option value=
"2">Needs Improvement</option>
                                             <option value=
"1">Unsatisfactory</option>
                                             <option value=
"0">N/A</option>
                                     </select>
                                  </td>
                         <td valign=
"top">#question#</td>

                     </tr>

                  </cfif>

                </cfloop>

Known Participant
April 29, 2014

opps my bad it did work , ignore reply .

thanks