Newbie Question (dropdown menu)
I'm trying to fill a combo-box (pardon the vb-centric lingo - I don't know what the things are called - it's a <select...><option...> thing) with items selected from a table. I haven't a clue how to do this. I've got the ODBC Connection and SQL Method working, but how do I iterate through the query results to fill a drop-down? Thanks Joel Grimes ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
Hi, Joel <untested> Just displaying the list in a <select>: <select name="whatever"> <dtml-in ZSQLMethodthatgetsthelist> <option value="<dtml-var theFieldname>"><dtml-var theFieldname></option> </dtml-in> </select> If "whatever" already has a value and you want that selected: <select name="whatever"> <dtml-in ZSQLMethodthatgetsthelist> <option value="<dtml-var theFieldname>" <dtml-if "whatever == theFieldname"> selected </dtml-if>> <dtml-var theFieldname></option> </dtml-in> </select> </untested> the </option> tags are apparently optional. hth -- Jim Washington joel grimes wrote:
I'm trying to fill a combo-box (pardon the vb-centric lingo - I don't know what the things are called - it's a <select...><option...> thing) with items selected from a table. I haven't a clue how to do this. I've got the ODBC Connection and SQL Method working, but how do I iterate through the query results to fill a drop-down?
Thanks
Joel Grimes
This is my answer to another seeker's question. It should also answer yours. This code assumes that the variable customerid on the form contains a value that matches up with customerid in the query custcompanysearch _______________________________________ <dtml-let tcustid="customerid"> <select name="customerid"> <dtml-in custcompanysearch> <option value=<dtml-var customerid> <dtml-if "customerid==tcustid">selected</dtml-if>> <dtml-var firstname> <dtml-var lastname></option> </dtml-in> </select> <dtml-let> __________________________________________________________________ Jim Sanford . Database Engineer / \ / Accelerated Technology, Inc. / / 720 Oak Circle Drive East / / \ Mobile, AL 36609 / / \ Voice: 334-661-5770 fax: 334-661-5788 / \ E-Mail: jsanford@atinucleus.com Web: http://www.atinucleus.com Nucleus. All You NEED in an RTOS. Royalty Free __________________________________________________________________ ----- Original Message ----- From: joel grimes <joelgrimes@hotmail.com> To: <zope@zope.org> Sent: Wednesday, June 21, 2000 10:51 AM Subject: [Zope] Newbie Question (dropdown menu) I'm trying to fill a combo-box (pardon the vb-centric lingo - I don't know what the things are called - it's a <select...><option...> thing) with items selected from a table. I haven't a clue how to do this. I've got the ODBC Connection and SQL Method working, but how do I iterate through the query results to fill a drop-down? Thanks Joel Grimes ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Jim Sanford -
Jim Washington -
joel grimes