[Zope] Filling a drop-down menu with SQL data (Problem with argument passing)

Thomas B. Passin tpassin@mitretek.org
Wed, 23 May 2001 10:45:20 -0400

You can't nest dtml elements within other ones.  So you can't write

<dtml-in expr="sqlShowTypes('<dtml-var Typ>')">

(as you have found out).  But you don't have to - you can simply refer to
the variable by its name within a dtml-xxx element.  So you could write

<dtml-in "sqlShowTypes(Typ)">

(you don't need the "expr=" part).  If your sqlShowTypes method is expecting
to receive a parameter with the name TypName, then your third try looks like
it ought to work.  However, we don't quite know where Typ is located.  If
you set it as a variable to the page's REQUEST, a ZSQL method should find it
without you having to pass it as a parameter:

<dtml-call "REQUEST.set('TypName',Typ')>

I also suggest that you check to see whether your Typ variable actually
contains data.  You can do this by writing a statement like

<dtml-var Typ>

at the place where you are trying to send it to sqlShowTypes.


Tom P


I have been trying and trying the whole day but I still have not found any
solution to my (simple?) problem:
=> I want to fill my HTML DropDown menu with data from a SQL table.

My first try was:
<dtml-in expr="sqlShowTypes('<dtml-var Typ>')">  : not working (Bad Request,
Error Value: ['Typname'])

2nd try:
<dtml-in expr="sqlShowTypes(TypName='<dtml-var Typ>')">   : somehow working
but my drop-down menu is filled with 5 empty spaces!

3rd try:
<dtml-in expr="sqlShowTypes(TypName=Typ)"   : again, somehow working but

I would need a proper statement that would embedd just fine in my drop-down
<dtml-in expr="....">
   <option> <dtml-var sequence-item>