• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

checking the checkbox in ValueList

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
</cfquery>

<CFSET GetidList = ValueList(Getthumbs.imageid)>


Any ideas?
0
COwebmaster
Asked:
COwebmaster
  • 3
  • 2
2 Solutions
 
wytcomCommented:
<cfoutput query="GetPictures">
  <cfif listFind("#GetidList#", GetPictures.imageid)>
      <cfset theChecked = "checked=\"checked\"">
  <cfelse>
      <cfset theChecked = "">
  </cfif>
  <input type="checkbox" #theChecked#>
</cfquery>

The above code provides a checkbox for each  picture and makes it checked if the imageid is in the list.
0
 
wytcomCommented:
<cfif listFind("#GetidList#", GetPictures.imageid) gt 0>

Probably better to do the check this way.
0
 
danrosenthalCommented:
slight improvement...(no need for pound signs and "gt 0")
<input type="checkbox" <CFIF listfind(getidlist,imagetocheck)>checked</cfif>
0
 
wytcomCommented:
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.
0
 
danrosenthalCommented:
I always seem to forget that one.
At least I am consistent!
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now