Skip to main content
Known Participant
April 7, 2009
Question

What is wrong with this code, does not work ?

  • April 7, 2009
  • 3 replies
  • 843 views

I have a page where I display line items. I have a checkbox next to each so that if I want to delete that line, I check the box. Here is the code :

<td valign="top" class="TitleText" align="center">
<cfinput type="checkbox" name="delRecords" value="#serialNumberID#"></td>
<td valign="top" class="TitleText" align="center">#conditionCode#</td>
<td valign="top" class="TitleText" align="center">#materialNumber#</td>
<td valign="top" class="TitleText" align="center">#quantity#</td>
<td valign="top" class="TitleText" align="center">#dollarformat(unitValue)#</td>

I do not acutally delete but update a status flag to 0. This is what I am doing :

update gfmSerialNumbers
  set status = 0
  where serialNumberID IN (#listQualify(form.delRecords, "'")#)

However, it is now working since the status flag is never 0. What am I doing wrong ?

This topic has been closed for replies.

3 replies

Inspiring
April 17, 2009

Ian and BKBK both gave good answers.  In addition to what they said,

run a select query with the same where clause as your update query, and cfdump it and then cfabort your template.  Do you get any records?  If so, take out the cfabort, and do that select/dump thing before and after your update.  Did the data change?  If it did, what made you think it wasn't changing before?

BKBK
Community Expert
Community Expert
April 17, 2009

It seems you want to get a comma-delimited list from form.delRecords. Then put the code <cfdump var="#form#"> in the action page. Experiment by submitting after switching the checkbox on and off. You will find that form.delRecords isn't the comma-delimited list you expect.

To get such a list you should have two or more form fields named delRecords. Even then, it is a shaky idea. Forms only submit checkboxes that have been checked.

ilssac
Inspiring
April 7, 2009

Looks pretty good for the code you shown.  As usualy I would recomended one to use the <cfqueryparam ...> tag.

where serialNumberID IN (<cfqueryParam value="#form.delRecords#" list="yes" cfsqltype="cfsqlinteger">)

But that will functionally work the same as your code, just be much safer.

To actually debug your code, you need to see what is being output for the form controls, look at the source.  And see what is being returned to the sever in the form request, <cfdump var="#form#"> at the top of the action page.

Does the data look like it should?