Evaluating a dynamic variable
Hi I'm trying to write a little function to create, populate and select defaults for list type drop down menus, what I have works, but there is a small problem.
The select control name is passed as an argument to the function:
<li>
<label for="type">Type</label>
<select name="type" id="type" />
<cfscript>selectOptions('type','VehicleTypes','type','id');</cfscript>
</select>
</li>
When the function gets a hold of it it needs to be eveluated, I'm using 'evaluate()' - but I understand that there are problems with evaluate.
Is there another method to do this? [i.e. address the value of a dynamic variable] See below.
<cffunction name="selectOptions" access="public" output="yes" returntype="string">
/*------ unrelated code removed -----*/
<cfscript>
for (i = 1;i lte showoptions.recordcount;i++){
vlu = showoptions[value];
txt = showoptions[column];
if(evaluate(formvar) is vlu){sel = 'selected="selected"';}else{sel=formvar&' '&vlu;}
options = options&'<option value="'&vlu&'" '&sel&' >'&txt&'</value>';
}
writeoutput(options);
</cfscript></cffunction>
-thanks
-sean
