Skip to main content
Inspiring
April 15, 2008
Question

Help with code

  • April 15, 2008
  • 3 replies
  • 596 views
I got this code from another user, seems to work but has a minor problem.

It reads a query and produces line items on a form, using #currentrow#. I then pass the values to the action page to update, which is below :

<cfloop from="1" to="#form.record_count#" index="row">

<cfif isDefined("form.urdn_line_item#row#")>
<cfparam name="form.urdn_line_item#row#">
<cfelse>
<cflocation url="close_disposition_urdn_line_items.cfm?urdn_number=#urdn_number#&coming_from_error=radio_buttons">
</cfif>

<cfparam name="form.instructions#row#">
<cfparam name="form.tracking_number#row#">
<cfparam name="form.urdn_action#row#">
<cfparam name="form.urdn_line_item#row#">
<cfparam name="form.urdn_number#row#">


<cfset instructions = form["instructions"& row]>
<cfset tracking_number = form["tracking_number"& row]>
<cfset urdn_action = form["urdn_action"& row]>
<cfset urdn_line_item = form["urdn_line_item"& row]>
<cfset urdn_number = form["urdn_number"& row]>


<cfquery name="qryUpdate_urdn_line_items" datasource="recDisc">
update tblUnReceivables_urdn_line_items
set tracking_number = '#tracking_number#',
<cfif instructions is "">
instructions = 'None'
<cfelse>
instructions = '#instructions#'
</cfif>
where urdn_number = '#urdn_number#'
and urdn_line_item = '#urdn_line_item#'
and urdn_action = '#urdn_action#'
</cfquery>

</cfloop>

The problem that I am having is that if a value is 123456 and I try to update it with 99999, the value acutally becomes 123456,99999 in the sql table, instead of 99999 overriding 123456.

How do I correct this ?

Thanks
    This topic has been closed for replies.

    3 replies

    talofer99
    Inspiring
    April 15, 2008
    Well I can see 2 things :
    1. in the sec code, the var urdn_action + urdn_line_item + urdn_number will only exists if qryGet_Disposition.urdn_action = other !!
    is it suppos to be like this ?
    2. try and use : Evaluate("form.tracking_number#row#")

    Tal

    tclaremont
    Inspiring
    April 15, 2008
    It looks like your problem is the following statement:

    <cfset tracking_number = form["tracking_number"& row]>

    Take out the "tracking_number", leaving just row.
    trojnfnAuthor
    Inspiring
    April 15, 2008
    All the other variables have this format, so I just added it, with row.

    If I remove the tracking_number and just leave row, what about the others ?
    talofer99
    Inspiring
    April 15, 2008
    Did you check the form structor ?
    Maybe the problem is in the form values you get when submiting the form ?
    You can check that by enableing the Debug option in CF admin ...
    If its not a problem in the dat you recive, post the form submiting page so I can look at it.

    Tal.
    trojnfnAuthor
    Inspiring
    April 15, 2008
    Here is the code from my form. I only display the tracking number for updating if the action is receive, otherwise I just display it if the action is rtv and nothing if the action is other. I have to do all three otherwise the row function blows up adn says it is missing a row.

    <td align="left" valign="top" width="253">
    <cfif qryGet_Disposition.urdn_action is "Receive">
    RR Number: <cfinput type="text" name="tracking_number#currentrow#" value="#qryGet_Disposition.tracking_number#">
    <input type="hidden" name="tracking_number#currentrow#" value="#qryGet_Disposition.tracking_number#"><br>
    <cfelseif qryGet_Disposition.urdn_action is "RTV">
    PMR: #qryGet_Disposition.tracking_number#
    <input type="hidden" name="tracking_number#currentrow#" value="#qryGet_Disposition.tracking_number#"><br>
    <cfelseif qryGet_Disposition.urdn_action is "Other">
    <input type="hidden" name="tracking_number#currentrow#" value="#qryGet_Disposition.tracking_number#"><br>
    <font face="arial" size="2">Comments:</font><br>
    <textarea name="instructions#currentrow#" cols="30" rows="5">#qryGet_Disposition.instructions#</textarea>
    <input type="hidden" name="urdn_action#currentrow#" value="#qryGet_Disposition.urdn_action#">
    <input type="hidden" name="urdn_line_item#currentrow#" value="#qryGet_Disposition.urdn_line_item#">
    <input type="hidden" name="urdn_number#currentrow#" value="#qryGet_Disposition.urdn_number#">
    </cfif>
    </td>