Error Using CFINPUT

Trying to create a form that checks or unchecks a checkbox based on the value of a field. Getting some non-descript errors. Can someone take a look and help?

<CFQUERY NAME="DirectoryInfo" DATASOURCE="DirInfo">
SELECT *
FROM UserInfo
</CFQUERY>
<TABLE>
<TR>
<TD>Name</TD>
<TD>Phone</TD>
<TD>Directory</TD>
</TR>
<CFOUTPUT QUERY="DirectoryInfo">
<TR>
<TD>#LName#, #FName#</TD>
<TD>#PhoneNo#</TD>
<TD><CFINPUT TYPE="checkbox" NAME="Directory"
    <CFIF #Directory# IS "1">
      CHECKED="Yes"
    </CFIF>
    >
</TD>
</TR>
</CFOUTPUT>
</TABLE>
SianneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rod_nolanCommented:
Try the suggestions below to get this code up and running...


1. The following code:
<CFIF #Directory# IS "1">
   CHECKED="Yes"
</CFIF>

should simply be:
<CFIF #Directory# IS "1">
   CHECKED
</CFIF>

In other words, the CHECKED attribute doesn't require a value. It just has to be present.

2. You're not using any of the <CFINPUT> specific attributes in this example so <CFINPUT> is unnecessary in this case; a regular <INPUT> will do.

If you do have a compelling reason to  use <CFINPUT>s they must appear inside a set of <CFFORM> tags. IN any case, you should always put form controls inside <FORM> tags.

3. You don't use variable prefixes when you output your query results. Although you may be able to get your code to work without them in some cases, it's always best to use the proper variable prefixes.

This is a little better:

<CFOUTPUT QUERY="DirectoryInfo">
<TR>
<TD>
  #DirectoryInfo.LName#,
  #DirectoryInfo.FName#
</TD>
<TD>
  #DirectoryInfo.PhoneNo#
</TD>
<TD>
<FORM action="actionpage.cfm"
      method="POST">
 <INPUT
     TYPE="checkbox"
     NAME="Directory"
<CFIF #DirectoryInfo.Directory# IS "1">
     CHECKED
</CFIF>
 >
</FORM>
</TD>
</TR>
</CFOUTPUT>


Good luck,
Rod

PS: No matter how non-descript the error messages might seem, they're always helpful when trying to figure out the source of a problem. It's best to always post them along with your code. =)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SianneAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.