troubleshooting Question

Drop-down value on update entering list item not value

Avatar of earwig75
earwig75 asked on
ColdFusion Language
21 Comments1 Solution502 ViewsLast Modified:
I have a drop-down that populates with some items/values from a reference table. When a choice is selected the value is written to the master table; this works fine.

When the record is edited the drop down is populated with the value that was previously selected (this is what I want to happen) but if the drop-down doesn't change it passes along the item name instead of what i want - the (numeric) value.

Could someone help with this? Would I have to change my update statement somehow so it displays the item name but still captures the value? Below is an example of what I currently have on my update (the relevant code).

CFC

 <cffunction name="update"
             returntype="boolean"
             hint="Update a record">
<cfargument name="ReferenceNumber"
              type="numeric"
              required="yes"
              hint="Reference Number">
<cfargument name="OfferType"
              type="string"
              required="no"
              hint="Offer Type">

<cfquery datasource="#datasource#">
  UPDATE [DB].[dbo].Tbl_Record_Master
  SET OfferType=<cfqueryparam value = "#ARGUMENTS.OfferType#" CFSQLType = "CF_SQL_VARCHAR">, ..........

WHERE ReferenceNumber=#ARGUMENTS.ReferenceNumber#
  </cfquery>
  <cfreturn true>

 </cffunction>

<cffunction name="GetOfferTypes"
             returntype="query"
             hint="Get Offer Types">

  <cfquery datasource="#Datasource#"
           name="offertypes">
  SELECT OfferTypeID, OfferType
  FROM [DB].[dbo].Rtbl_Record_OfferType
  ORDER BY OfferTypeID
  </cfquery>
  <cfreturn offertypes>

 </cffunction>

Form page

<cfinvoke component="myCFC"
           method="get"
           ReferenceNumber="#URL.CFGRIDKEY#"
           returnvariable="record">

 <cfset OfferType=record.OfferType>

<cfinvoke component="myCFC"
           method="GetOfferTypes"
           returnvariable="offertypes">

<cfform action="process.cfm">
     <SELECT NAME="OfferType">
       <cfoutput><OPTION>#VARIABLES.OfferType#</OPTION></cfoutput>
            <CFOUTPUT QUERY="OfferTypes">
                  <OPTION VALUE="#OfferTypeID#">#OfferType#</OPTION>
            </CFOUTPUT>
      </SELECT>            


Process page

<cfinvoke component="myCFC"
          method="Update">

<cfinvokeargument name="OfferType"
                   value="#FORM.OfferType#">
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 21 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros