Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 5th, 2004, 08:19 PM
zci zci is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 17 zci User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 31 sec
Reputation Power: 0
Unhappy Populating dropdowns

I'm trying to dynamically populate a dropdown fom a database MySQL db using Python. I am stuck. Can somebody please help on how to get started or point in right direction? Thanks in advance!

Reply With Quote
  #2  
Old March 5th, 2004, 09:44 PM
jimmy2k1 jimmy2k1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 89 jimmy2k1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 48 m 50 sec
Reputation Power: 7
so what exactly don't you understand? you grab the info out of the db and write it in the HTML form.

Reply With Quote
  #3  
Old March 6th, 2004, 06:34 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,532 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 38 m 15 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
As 2k said, there isn't really a lot to get stuck on here but anyway here's a little example - this doesn't use any db since i don't have any data to populate this t with.

Code:
#!/usr/bin/env python

print 'Content-Type: text/html\n'

values = ['Name1', 'Name2', 'Name3', 'Name4']

print'<form name="form">'
print'<select name="names">'
print'<option selected>Netytan</option>'

for value in values:
    print'<option>%s</option>' % value

print'</select>'
print'</form>'


Note: 'values' can be a simple cursor or list/tuple object. needs a little reworking if you want to use dictionaries but it shows you exactly what you need.... so, a loop

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #4  
Old March 19th, 2004, 11:48 AM
zci zci is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 17 zci User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 31 sec
Reputation Power: 0
Talking

Thanks netytan. I kinda figured out myself but appreciate your example!

Quote:
Originally Posted by netytan
As 2k said, there isn't really a lot to get stuck on here but anyway here's a little example - this doesn't use any db since i don't have any data to populate this t with.

Code:
#!/usr/bin/env python

print 'Content-Type: text/html\n'

values = ['Name1', 'Name2', 'Name3', 'Name4']

print'<form name="form">'
print'<select name="names">'
print'<option selected>Netytan</option>'

for value in values:
    print'<option>%s</option>' % value

print'</select>'
print'</form>'


Note: 'values' can be a simple cursor or list/tuple object. needs a little reworking if you want to use dictionaries but it shows you exactly what you need.... so, a loop

Mark.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Populating dropdowns


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway