Copy link to clipboard
Copied
Lets say that I have the following:
<cfselect name="city" value="unid" display="city" bind="cfc:Examples.CFC.Geographic.getAllCities()" bindonload="true" onChange="submit()" />
This will return all the countries in our system. When the form submits onChange, the value changes to the city at the top of the list.
How do I get the cfselect to default to the value selected when it was previously changed ?
Copy link to clipboard
Copied
use the selected attribute
Copy link to clipboard
Copied
I attempt to pass a variable as the selected value, it always defaults to the top value returned from the cfc.
Copy link to clipboard
Copied
Is the variable you are passing one of the available values?
Copy link to clipboard
Copied
Yes
I can try again when I get home. So the Selected should work ?
Copy link to clipboard
Copied
You are not crazy...it does NOT work. I have seen some solutions that required putting the selected item at the top of the list and another that rewrote the Ajax.
Copy link to clipboard
Copied
How do I get the cfselect to default to the value selected when it was previously changed ?
<cfform preservedata="yes">