Connecting Tech Pros Worldwide Help | Site Map

Trying to retrieve checkbox variable name

Familiar Sight
 
Join Date: Sep 2007
Posts: 221
#1: Oct 23 '07
I'm populating some checkboxes from a query result. I'm having a problem retrieving the data to file it to my database. How do I retrieve the checkbox values when the names are variable names? I need to get all of the checkbox values and their on/off value.

Expand|Select|Wrap|Line Numbers
  1. <ol class="comments">
  2.     <cfoutput query="getComments">
  3.                 <cfif (category eq 2)>
  4.                      <li><input type="checkbox" class="noBox" name=#commentID# value=#commentID# onClick="javascript:readCheck(this)">#comment#</option></li>
  5.                 </cfif>
  6.                 </cfoutput>
  7.                </ol>
  8.  
Submit page which errors on the commentID:

Expand|Select|Wrap|Line Numbers
  1. <cfoutput>#commentID#</cfoutput>
  2.  
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Oct 24 '07

re: Trying to retrieve checkbox variable name


If you don't know what commentID will be, set a hidden form element to that name so that you can use it or alternatively, loop over the form variables until you get to the checkbox variable.
Familiar Sight
 
Join Date: Sep 2007
Posts: 221
#3: Oct 24 '07

re: Trying to retrieve checkbox variable name


Is there a better way to name my checkbox names? I have been trying to figure out how I'm supposed to retrieve the value when the name of my input's are variable names.
Familiar Sight
 
Join Date: Sep 2007
Posts: 221
#4: Oct 24 '07

re: Trying to retrieve checkbox variable name


How would I go about looping on all form variables on my submission page?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Oct 24 '07

re: Trying to retrieve checkbox variable name


Quote:

Originally Posted by dmorand

How would I go about looping on all form variables on my submission page?

See this thread.
Familiar Sight
 
Join Date: Sep 2007
Posts: 221
#6: Oct 24 '07

re: Trying to retrieve checkbox variable name


Sweet, thats exactly what I needed. Thanks acoder!!
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#7: Oct 24 '07

re: Trying to retrieve checkbox variable name


No problem, you're welcome as always.
Reply