I am a newbie and hope that someone can help. I have a <cfform that adds and updates records. I have 3 <cfselect statements that are dynamic. I user the selected attribute to display the current value if this is an update. The first one works fine.

The 2nd and 3rd will not show the current value when updating. They both show the initial value. The values are saved in the table correctly. The values are not related. Here is a sample of 2 of the selects.

<td>
 <cfselect enabled="No"
            	name="dept_code"
                size="1"
            	id="dept_code"
            	required="yes"
            	message="Please select a Valid Department Code"
            	multiple="no"
            	query="list_active_depts"
                value="dept_code"
                display="dept_code_desc"
                selected="#user_dept_code#" onChange="#user_dept_code#"
               	queryPosition="Below">
             </cfselect>
</td>
<tr>
<td>
<cfselect name="Fstp_code"
                size="1" id="Fstp_code"
            	required="yes"
            	message="Please select a Valid FSTP Code"
            	multiple="no"
            	query="list_active_fstp"
                value="fstp_code"
                display="fstp_code_desc"
               	queryPosition="below"
                selected="#user_fstp_code#"     onChange="#User_fstp_code#">
             </cfselect>

Any help would be greatly appreciated.

Did you verify the "selected" values actually exist in the query?

Other than that the code looks okay except for the onChange. OnChange accepts javascript/actionscript. But it looks like you are passing in the selected value instead, which probably wouldn't work.

I took out the "onchange" and the 2nd cfselect began working. I believe that the values for the 3rd select are populated. I am trying to make sure of that now.

the selected attribute does not work unless it is used in conjunction with the 'query' attribute. In other words, this won't work:
<cfselect name="CTitle" selected="#rec.CTitle#">
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
</cfselect>

-BUT...this WILL work-
<cfselect name="CTitle" query="recCT" display="ctitle" value="ctitle" queryPosition="below" selected="#rec.CTitle#">
<option value=""></option>
</cfselect>

ALSO - I've found that when making changes to your code, then hitting the 'refresh' button doesn't always actually 'refresh' the page. Be sure to hit the 'CTRL' + 'F5' key to do a 'hard refresh'.

bregan507

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.