I am trying to make a value from an SQL query the selected one from an HTML option list. But the following doesn't work and I can't see why. <td> <select name="Type"> <option <dtml-if expr="'<dtml-var Type>'=='Call'">SELECTED</dtml-if>> Call <option <dtml-if expr="'Meeting'=='<dtml-varType>'">SELECTED</dtml-if>> Meeting <option <dtml-if expr="'<dtml-var Type>'=='Letter'">SELECTED</dtml-if>> Letter </option></select> </td> <td><select name="Priority"> <option <dtml-if expr="'<dtml-var Priority>'=='1'">SELECTED</dtml-if>> 1 <option <dtml-if expr="'<dtml-var Priority>'=='2'">SELECTED</dtml-if>> 2 </option></select> </td> Any thoughts ? Tim Considine Email : timc@bizdev.co.uk
There are too many things wrong here. First of all, always make sure to put your select elemetns, etc., inside a <form> element. Internet Explorer will display them anyway, Netscape will not. More important, you can't use a <dtml-...> tag inside another one, nor do you have to. For example, you can write <option <dtml-if "Priority==1">SELECTED</dtml-if>> 1 (using "expr=" is optional, and it's simpler if you don't use it). In other words, once you start a dtml tag, everything inside is interpreted as dtml statements (for names not in quotes) or Python expressions (for everything within double quotes) until the end of the tag. Once corrected, in <option <dtml-if expr="'<dtml-var Type>'=='Call'">SELECTED</dtml-if>> Python probably won't know what Type is unless you have already defined a variable for it in some way. For example, if it's an ordinary variable, you can reference it as "_['Type']=='Letter' ". Finally, what is to prevent your code from trying to set more than one option as SELECTED? If that's what you want you have to tell the <select> element to allow multiple selections. Otherwise you have to make sure it can't happen. Cheers, Tom P [Tim Considine] I am trying to make a value from an SQL query the selected one from an HTML option list. But the following doesn't work and I can't see why. <td> <select name="Type"> <option <dtml-if expr="'<dtml-var Type>'=='Call'">SELECTED</dtml-if>> Call <option <dtml-if expr="'Meeting'=='<dtml-varType>'">SELECTED</dtml-if>> Meeting <option <dtml-if expr="'<dtml-var Type>'=='Letter'">SELECTED</dtml-if>> Letter </option></select> </td> <td><select name="Priority"> <option <dtml-if expr="'<dtml-var Priority>'=='1'">SELECTED</dtml-if>> 1 <option <dtml-if expr="'<dtml-var Priority>'=='2'">SELECTED</dtml-if>> 2 </option></select> </td> Any thoughts ?
participants (2)
-
Thomas B. Passin -
Tim Considine