Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to loop to get value of all checked checkboxes?

New Here ,
Nov 15, 2013 Nov 15, 2013

I am a non-techic trying to fix something for work. Your help is really appreciated.

I have a form with checkboxes (4 check boxes). Everything sumbits fine. SQL db is updated perfectly and data is displayed on webpage w/o any problem. However when I go to edit an entry, on the edit form, (if more then one checkbox were selected oringally), non of the checkboxes are checked. If only one checkbox was selected orinally, that checkbox is selected. What am I missing? I know I am suppose to use loop to get all checked checkbox values, but I have no idea how.

Here is my code so far.


<input type="checkbox" name="colors" value="red" <cfif #getResultSet.colors# EQ "red">checked</cfif>>red
    <input type="checkbox" name="colors" value="blue" OR<cfif #getResultSet.colors# EQ "blue">checked</cfif>>blue
    <input type="checkbox" name="colors" value="green" OR<cfif #getResultSet.colors# EQ "green"></cfif>>green
    <input type="checkbox" name="colors" value="yellow" OR<cfif #getResultSet.colors# EQ "yellow">checked</cfif>>yellow

TOPICS
Getting started
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 21, 2013 Nov 21, 2013
LATEST

JayYaj wrote:

However when I go to edit an entry, on the edit form, (if more then one checkbox were selected oringally), non of the checkboxes are checked. If only one checkbox was selected orinally, that checkbox is selected.

You've given all the checkboxes the same name. Give them each a unique name and you will be able to access them individually. Current standards also require a unique ID, which can (but does not have to) be the same as the name.

The "OR" characters in your code are not doing anything. You can safely delete them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources