获取响应从蟒蛇到浏览器(CGI蟒蛇)

问题描述 投票:2回答:1

我试图让,只要我选择从下拉菜单中选择选项(反映)对应的单选按钮。我无法得到答案,我是新来的蟒蛇。可能你们,请帮助,下面是我的代码:

HTML代码:

<!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>

我的意料,当我选择任何计费/ MCR下拉列表中,单选按钮应该动态地生/ STD名称生成。

dropdown.py文件代码:

 #!/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>")
python-2.7
1个回答
1
投票

如果我很理解你需要做的是在HTML文件中使用AJAX(jQuery的),它发送请求异步地处理它,你点击你的Python文件。也许这个链接可以帮助你jQuery get value of select onChange

© www.soinside.com 2019 - 2024. All rights reserved.