Skip to main content
Inspiring
May 7, 2014
Question

CFIF control form display

  • May 7, 2014
  • 1 reply
  • 449 views

I want to use following code to control elements on the form.

I use cfoutout that it shows the value is 0, but the cfif control does not show the cfselect on the form.

Is it the right way to do control on the form?

Your help and information is great appreciated,

Regards,

Iccsi,

<cfoutput>

           FORM site "#form.MySite#"

         

    </cfoutput>

<CFIF structKeyExists(form,MySite)>

      <cfif "#form.MySite#" EQ "0">

           <tr>

             <td>

               <cfselect name="Mylst" id="Mylst">

            </td>

           </tr>

  </cfif>

</cfif>

    This topic has been closed for replies.

    1 reply

    Dave Ferguson
    Participating Frequently
    May 7, 2014

    Try this instead.  You had the syntax wrong for stuctKeyExists and the conditional in the 2nd if was not quite right.  Also, for simplicity, you can combine both ifs into one.  Also, with pound signs, you only need to use them when you are going to output the var or it has to be quoted for some reason.

    <cfif structKeyExists(form, "MySite") && form.mysite == "0">

               <tr>

                 <td>

                   <cfselect name="Mylst" id="Mylst">

                </td>

               </tr>

    </cfif>

    HTH,

    --Dave