- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- 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 Radio Button Data to CGI Program in Python
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 −
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\n\r\n" 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 Radio Button Data to Python CGI script?
- Passing Checkbox Data to CGI Program in Python
- Passing Text Area Data to CGI Program in Python
- Passing Drop Down Box Data to CGI Program in Python
- Using Selenium in Python to click/select a radio button.
- First CGI Program in Python
- How to use Radio button in Android?
- Bootstrap Form Radio Button
- How to use Radio Button in Android Kotlin?
- How to select a radio button in a page in Selenium with python?
- How to pass Text Area Data to Python CGI script?
- How to add radio button list in alert dialog?
- How to create a Radio Button using JavaFX?
- How to pass Checkbox Data to Python CGI script?\n\n
- How to pass Drop Down Box Data to Python CGI script?