Mark,

You need to add "SELECTED" to the element in the drop-down which matches the
value in the record you are updating.

Here's some pseudo-code:

<CFOUTPUT query="myQueryOfSelectValuesAndContents">
        <option value="#myQueryOfSelectValuesAndContents.value#" 
                <cfif myQueryOfSelectValuesAndContents.value EQ
myQueryOfTheRecordBeingUpdated.theFieldValue>SELECTED</cfif>
        #myQueryOfSelectValuesAndContents.value#</option>
</CFOUTPUT>


-----Original Message-----
From: Marc Garrett [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 23, 2001 2:18 PM
To: CF-Talk
Subject: problem with list box update


I have an update page on which I need to show "user friendly" terms in a
select box, even though the information in the table is actually a code
number (e.g., the info is saved as "010-000" but the user should see
"services.") The value from the select is then passed to a CFUPDATE on the
following page. I can get the update to work properly if the user changes
the value in the select box, but if she leaves the value unchanged the field
gets updated to the "friendly" word instead of leaving the code value
unchanged. 

Thanks for any assistance. I have included code below my sig.

Regards,

Marc Garrett

Here's the code that populates the select list:

<select class="editBox" name="fldCategory1">
    <option><cfoutput query="category_1">#fldCategory#</cfoutput></option>
    <cfloop query="categories">
    <option
value="<cfoutput>#fldCategoryID#</cfoutput>"><cfoutput>#fldCategory#</cfoutp
ut></option>
    </cfloop>  
</select>

Here's query category_1:

<cfquery datasource="datasource" name="category_1">
SELECT
 tblContacts.fldContactID,
 tblContacts.fldCategory1,
 tblCategories.fldCategory,
 tblCategories.fldCategoryID
FROM
 tblContacts, tblCategories
WHERE
 tblContacts.fldContactID LIKE '#id#'
 AND tblCategories.fldCategoryID = tblContacts.fldCategory1
</cfquery>

The update on the next page is simply:
<cfupdate datasource="datasource" tablename="tblContacts">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to