checking the checkbox in ValueList

Posted on 2006-04-19
Last Modified: 2013-12-24
Ok, I run a query which outputs some id numbers (variable GetidList).  On the same page I have a form with checkbox beside pictures with id numbers.  What I'm trying to attempt with no luck is checking the checkbox IF that id falls in that ValueList.  So, I have:

<cfquery datasource="dsn" name="Getthumbs">
Select imageid
FROM formnav

<CFSET GetidList = ValueList(Getthumbs.imageid)>

Any ideas?
Question by:COwebmaster
    LVL 7

    Expert Comment

    <cfoutput query="GetPictures">
      <cfif listFind("#GetidList#", GetPictures.imageid)>
          <cfset theChecked = "checked=\"checked\"">
          <cfset theChecked = "">
      <input type="checkbox" #theChecked#>

    The above code provides a checkbox for each  picture and makes it checked if the imageid is in the list.
    LVL 7

    Expert Comment

    <cfif listFind("#GetidList#", GetPictures.imageid) gt 0>

    Probably better to do the check this way.
    LVL 15

    Accepted Solution

    slight improvement...(no need for pound signs and "gt 0")
    <input type="checkbox" <CFIF listfind(getidlist,imagetocheck)>checked</cfif>
    LVL 7

    Assisted Solution

    Very cool.  I'm not used to putting cfif tags inside html tags - good idea.

    <input type="checkbox" <CFIF listfind(getidlist,imagetocheck)>checked</cfif> >

    I added the > to close the input tag to the end.
    LVL 15

    Expert Comment

    I always seem to forget that one.
    At least I am consistent!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
    One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now