I have a CF generated flash form that I would like to use to edit address records. The form has a <cfselect><option> list of states. When the form opens I do a remote query to retieve an address record from the database. I can populate the forms' <cfinput> tags from the query, but have not found a way to select the proper <option> in the <cfselect>. Any hints? Thanks.
I can tell you what I finally did to get on with the project. I did a pre-query to find the data needed to identify the desired <option> tag to select. Then I used a <cfif> tag to set the option while building the flash form. This seems a pretty silly way to get there and I need to regenerate the from for each record. But I needed to move on.
I would assume that the returned address record has a state id ? Then in the onresult of the remote call, just loop through the cfselect list Lets assume the select list is called "myselect", then //bring the form field into scope var myselect = myselect //loop through the select list for(var x=0; x < myselect.length; x++){ if(myselect.getItemAt(x).data == results.getItemAt(0).stateID){ myselect.selectedIndex = x; } } Ken
Good suggestion. I went back to the code to give it a try and have had mixed success. The basic idea works, however, bringing the <CFSELECT ...> into scope is iffy. It works properly the first time after I restart the CF server and about 1 in 10 times after that. There are no problems with any other <CFFORM ....> fields. Thanks.
Don't see what you're looking for? Try a search.
|