PythonistL wrote: > Luke, > Thanks for your reply.But I am not sure I fully understand your reply. > (I might have put my question in a not clear way). > All that I need is to render the user's choice so that in a template > there is no value but the label. > > E.g. the new_data( taken from a form ) may be like this: > {'Password1': ['bb'], 'Fax': [''], 'Drop-Down Menu': ['2'], 'Login2': > ['[EMAIL PROTECTED]'],} > > where Drop-Down Menu loks like this > > <p><select name="Drop-Down Menu" size="1"> > > <option value="1">Choice 1</option> > > <option value="2">Choice2</option> > > </select></p> > > and I need to put in a template "Choice2" not "2".
If the only place that "Choice2" appears is in your template, then the only way to get hold of it inside Django is by not specifying a "value" attribute on the "option" element. This is standard HTML (which was what look was trying to say): you do not get access to the contents of an option element _unless_ there is no value attribute specified (in which case the default initial value for the element is its content -- see section 17.6 of the HTML spec). So either you need to keep track of the association between the value "2" and the text string "Choice2" in your code as well as your template (violates 'don't repeat yourself') or you can pass back "choice2" as part of your form (rather than "2") or you can build up the template dynamically, inserting both "2" and "Choice2" as part of a list (so you only store the association between the two in one place -- your code, not the template). Best wishes, Malcolm