- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Passing Drop Down Box Data to CGI Program in Python
Drop Down Box is used when we have many options available but only one or two will be selected.
Here is example HTML code for a form with one drop down box −
<form action = "/cgi-bin/dropdown.py" method = "post" target = "_blank"> <select name = "dropdown"> <option value = "Maths" selected>Maths</option> <option value = "Physics">Physics</option> </select> <input type = "submit" value = "Submit"/> </form>
The result of this code is the following form −
Below is dropdown.py script to handle input given by web browser.
#!/usr/bin/python # Import modules for CGI handling import cgi, cgitb # Create instance of FieldStorage form = cgi.FieldStorage() # Get data from fields if form.getvalue('dropdown'): subject = form.getvalue('dropdown') else: subject = "Not entered" print "Content-type:text/html\r
" print "<html>" print "<head>" print "<title>Dropdown Box - Sixth CGI Program</title>" print "</head>" print "<body>" print "<h2> Selected Subject is %s</h2>" % subject print "</body>" print "</html>"
- How to pass Drop Down Box Data to Python CGI script?
- Passing Checkbox Data to CGI Program in Python
- Passing Radio Button Data to CGI Program in Python
- Passing Text Area Data to CGI Program in Python
- How to get selected text from a drop-down list (select box) using jQuery?
- First CGI Program in Python
- How to pass Checkbox Data to Python CGI script?
- How to select a drop-down menu option value with Selenium (Python)?
- How to select/get drop down option in Selenium 2?
- How to raise a "File Download" Dialog Box in Python CGI Programming?
- How to pass Radio Button Data to Python CGI script?
- How to pass Text Area Data to Python CGI script?
- How to install guake drop down terminal terminal on ubuntu
- How to include an option in a drop-down list in HTML?
- How to write Python CGI program to interact with MySQL?