- 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
How to pass Radio Button Data to Python CGI script?
Passing Radio Button Data to CGI Program
Radio Buttons are used when only one option is required to be selected.
Here is example HTML code for a form with two radio buttons −
<form action = "/cgi-bin/radiobutton.py" method = "post" target = "_blank"> <input type = "radio" name = "subject" value = "maths" /> Maths <input type = "radio" name = "subject" value = "physics" /> Physics <input type = "submit" value = "Select Subject" /> </form>
The result of this code is the following form −
Maths Physics Select Subject
Below is radiobutton.py script to handle input given by web browser for radio button −
#!/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('subject'): subject = form.getvalue('subject') else: subject = "Not set" print "Content-type:text/html\r
" print "<html>" print "<head>" print "<title>Radio - Fourth CGI Program</title>" print "</head>" print "<body>" print "<h2> Selected Subject is %s</h2>" % subject print "</body>" print "</html>"
- How to pass Checkbox Data to Python CGI script?
- How to pass Text Area Data to Python CGI script?
- Passing Radio Button Data to CGI Program in Python
- How to pass Drop Down Box Data to Python CGI script?
- How to process a simple form data using Python CGI script?
- How to execute Python CGI Script on Apache Server?
- How to read all HTTP headers in Python CGI script?
- How to send the result of Python CGI script to the browser?
- How to use Radio button in Android?
- How to use Radio Button in Android Kotlin?
- How to create a Radio Button using JavaFX?
- Bootstrap Form Radio Button
- Using Selenium in Python to click/select a radio button.
- How to add radio button list in alert dialog?
- Passing Checkbox Data to CGI Program in Python