2

I am trying to get(reflect) corresponding radio button as soon as I choose the option from dropdown menu. I am unable to get the answer, I am new to python. could you guys please help , below is my code :

HTML CODE:

<!DOCTYPE html>
<html>
   <head>
      <title>
         Program
      </title>
      </head
   <body>
      <h3>
         first program :)
      </h3>
      <form action="/cgi-bin/mds/dropdown.py" method="post">
         <br>
         <select name="dropdown" >
            <option value="MCR" selected> MCR </option>
            <option value="OCS" > OCS </option>
         </select>
         <input type="radio" name="file" value="raw"> raw  <br />
         <input type="radio" name="file" value="std" /> std <br/>
         <input type="submit" value="Submit" />
      </form>
   </body>
</html>

My expectation when I select any of the OCS/MCR dropdown, the radio button should dynamically generate with raw/std name.

dropdown.py file code:

 #!/usr/bin/python

 import cgi
 import cgitb
 form = cgi.FieldStorage()
 if form.getvalue('dropdown'):
   menu = form.getvalue('dropdown')
 else :
   menu = "not entered"

 print("Content-type:text/html\r\n\r\n")
 print("<html>")
 print("<head>")
 print("<title>Hello - Second CGI Program</title>")
 print("</head>")
 print("<body>")
 print("<h2> %s </h2>" % (menu))
 print("</body>")
 print("</html>")
IMParasharG
  • 1,869
  • 1
  • 15
  • 26

1 Answers1

0

If i well understand you need to do that using ajax (jquery) in your html file, it sends request asynchronously to your python file that handles it as what you clicked on. maybe this link helps you jQuery get value of select onChange

Ayoub Benayache
  • 1,046
  • 12
  • 28