I would like to dynamically generate a list with an HTML SELECT tag where the displayed values are strings and the returned value is an integer code associated with that string I have access to two External Methods, one returns a list of strings and the other returns a list of codes associated with those strings: get_descriptions() and get_codes() The DTML I currently have is <SELECT NAME="race"> <dtml-in expr="get_descriptions()"> <OPTION VALUE="<dtml-var sequence-item>"><dtml-var sequence-item></OPTION> </dtml-in> </SELECT> but this returns the string selected, and I want the code returned, as I indicate below with 'code-here' <SELECT NAME="race"> <dtml-in expr="get_descriptions()"> <OPTION VALUE="code-here"><dtml-var sequence-item></OPTION> </dtml-in> </SELECT> I can add or modify the External Methods to return something more appropriate if necessary. Is there a way for an external method to return objects that would have 'code' and 'description' attributes that dtml-var could access? Thanks, John Hunter
use mapping attribute of dtml-in:
<SELECT NAME="race"> <dtml-in expr="get_descriptions()" mapping> <OPTION VALUE="<dtml-var code>"><dtml-var description></OPTION> </dtml-in> </SELECT>
You have to return a object-list from get_descriptions like the following: result = [] do a loop for objects: object = { 'code' : thema, 'description' : description } result.append(object) return result
Thanks, John Hunter
participants (2)
-
Dirk Datzert -
John Hunter