1 Reply Latest reply on May 7, 2014 6:57 AM by Dave Ferguson

    CFIF control form display

    iccsi Level 1

      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>

        • 1. Re: CFIF control form display
          Dave Ferguson Level 3

          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