Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing checkboxes

Status
Not open for further replies.

calista

Programmer
Jan 24, 2001
545
US
I am trying to write an edit routine that reads the database, selects the desired record, and populates the form that was originally used to input the data in the first place with that values in the database.

Part of my form is a dynamically generated list of checkboxes. The user may check one or more boxes, and the data is stored as a comma delimited list. I know how to display the data using CFLOOP, but how do I populate the form with the contents of the list?

The checkbox items are in a different table than the one the list is stored in.

Any ideas? Thanks!
 
I decided I should attach some code.

This is the code that generates the part of the form I am refering to:
Code:
<table width=&quot;80%&quot; align=&quot;center&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot; border=&quot;1&quot;>
<tr>
	<td width=&quot;80%&quot; align=&quot;center&quot;>Event Name</td>
	<td width=&quot;20%&quot; align=&quot;center&quot;>Event Number</td>
</tr>
<cfoutput query=&quot;GetEvents&quot;>
<tr>
    <td width=&quot;80%&quot;>
		<input type=&quot;Checkbox&quot; name=&quot;EventName&quot; value=&quot;#EventName#&quot;>#EventName#
	</td>
    <td align=&quot;right&quot;>#EventNumber#</td>
</tr>
</cfoutput>
</table>

The list is stored in a column called &quot;SystemEventGenered&quot;. I want to query the table that holds &quot;SystemsEventsGenered&quot; and used it to populate the table shown above. Hope this claifies things.
 
Is the list accessible in the same query of GetEvents? In other words, if you put #GetEvents.SystemEventGenered# would it output the list of boxes that were checked?
 
No. At this point, SystemEventsGenered is in a table called ServicesTable, and the Events (which are used to create the form) are in a table called EventTable. I want to output the entire list of events in case the user wants to add additional events to the list. I guess I could do a query on both tables at the same time. Hmmmm... I'll have to think about that one.
 
Hey Calista,

Is this what you're looking for? This assumes you do a query called Q1 to retrieve the comma separated list of values from the original submission.

<cfoutput query=&quot;GetEvents&quot;>
<tr><td width=&quot;80%&quot;>

<input type=&quot;Checkbox&quot; name=&quot;EventName&quot;

<cfif listfind( Q1.SystemEventGenered, eventName) > Checked </cfif>

value=&quot;#EventName#&quot;>#EventName#

</td><td align=&quot;right&quot;>#EventNumber#</td></tr>
</cfoutput>

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top