Filling a drop-down menu with SQL data (Problem with argument passing)
Hello everybody, 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 SQL Method (sqlShowTypes) takes one argument which I have defined in the Z SQL Method Properties as "TypeName". The function is as follows: SELECT Typ FROM <dtml-if expr="TypeName=='Researcher'> tblStaffResearchers <dtml-else>tblStaffManagement </dtml-if> When testing this method seperatly from the calling dtml document it works fine. After specifing a TypeName Parameter it returns all the rows from the Typ-column. Now, in my DTML Document I have a Variable "Typ" (either containing 'Researcher' or 'Management'). This one I want to pass to sqlShowTypes as the TypeName parameter. 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 again EMPTY SPACES! I would need a proper statement that would embedd just fine in my drop-down code: <dtml-in expr="...."> <option> <dtml-var sequence-item> </dtml-in></select> </td> If you are that Zope Guru I'm so badly in need of, please help me with that problem! PS.: "sequence-item" is the proper one to use in the code above, right? Thanks a lot, Philipp Robbel ________________________________________ Der clevere Infobote - Shopping-Tipps bequem abonniert. Jetzt neu bei http://www.epost.de
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. Cheers, Tom P [<philipp.robbel@epost.de>] 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 again EMPTY SPACES! I would need a proper statement that would embedd just fine in my drop-down code: <dtml-in expr="...."> <option> <dtml-var sequence-item> </dtml-in></select> </td>
On 23 May 2001, at 14:41, philipp.robbel@epost.de wrote:
SELECT Typ FROM <dtml-if expr="TypeName=='Researcher'> tblStaffResearchers <dtml-else>tblStaffManagement </dtml-if>
<dtml-in expr="sqlShowTypes(TypName=Typ)" : again, somehow working but again EMPTY SPACES!
<select name="selectedtypes:string"> <dtml-in "sqlShowTypes(_.None,_,TypName=Typ)"> <option value="&dtml-typ;">&dtml-typ;</option> </dtml-in> </select> Note that the Typ outside the dtml-in is not the same as that inside. I suggest you change the outside Typ to be "TypeName" or something.
participants (3)
-
Brad Clements -
philipp.robbel@epost.de -
Thomas B. Passin