Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Not seeing the display from a python script that is expected. Page source shows the correct data

more options

Running a python script

#!/usr/local/bin/python
print("Content-Type: text/html\n\n")
print("<!DOCTYPE html>")
print("<html>")
print("<body>")
import mysql.connector
mydb=mysql.connector.connect(
  host="localhost",
  user="root",
  password="XXXXXXXX",
  database="budget_2019"
)
cursorObject=mydb.cursor()
query="show tables"
cursorObject.execute(query)
print ("<table  class=box >")
print ("<TR><TH Colspan='1'>Expenses</TH></TR>")
print ("<form action=viewcf.php method=GET>")
print ("<input type=hidden name=mon value=7>")
print ("<input type=hidden name=year value=2023>")
myresult = cursorObject.fetchall()
for x in myresult:
	print("<TR><TD><input type=radio name=dbtable value={}></TD></TR>".format(x))
print("</form>")
print("</table>")
print("</body>")
print("</html>")
mydb.close()

Script runs successfully from the command line, giving this output Content-Type: text/html

<!DOCTYPE html>
<html>
<body>
<table  class=box >
<TR><TH Colspan='1'>Expenses</TH></TR>
<form action=viewcf.php method=GET>
<input type=hidden name=mon value=7>
<input type=hidden name=year value=2023>
<TR><TD><input type=radio name=dbtable value=('Charity',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Clothing',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Food',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Housing',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Insurance',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Medical',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Personal',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Recreation',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Taxes',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Transportation',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Utilities',)></TD></TR>
</form>
</table>
</body>
</html>

When run through Firefox I get the page seen in the attached image

Page Source from Tools->Browser Tools->Page Source looks like this

<!DOCTYPE html>
<html>
<body>
<table  class=box >
<TR><TH Colspan='1'>Expenses</TH></TR>
<form action=viewcf.php method=GET>
<input type=hidden name=mon value=7>
<input type=hidden name=year value=2023>
<TR><TD><input type=radio name=dbtable value=('Charity',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Clothing',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Food',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Housing',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Insurance',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Medical',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Personal',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Recreation',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Taxes',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Transportation',)></TD></TR>
<TR><TD><input type=radio name=dbtable value=('Utilities',)></TD></TR>
</form>
</table>
</body>
</html>

Running a python script <pre><nowiki>#!/usr/local/bin/python print("Content-Type: text/html\n\n") print("<!DOCTYPE html>") print("<html>") print("<body>") import mysql.connector mydb=mysql.connector.connect( host="localhost", user="root", password="XXXXXXXX", database="budget_2019" ) cursorObject=mydb.cursor() query="show tables" cursorObject.execute(query) print ("<table class=box >") print ("<TR><TH Colspan='1'>Expenses</TH></TR>") print ("<form action=viewcf.php method=GET>") print ("<input type=hidden name=mon value=7>") print ("<input type=hidden name=year value=2023>") myresult = cursorObject.fetchall() for x in myresult: print("<TR><TD><input type=radio name=dbtable value={}></TD></TR>".format(x)) print("</form>") print("</table>") print("</body>") print("</html>") mydb.close() </nowiki></pre><br> Script runs successfully from the command line, giving this output Content-Type: text/html <pre><nowiki><!DOCTYPE html> <html> <body> <table class=box > <TR><TH Colspan='1'>Expenses</TH></TR> <form action=viewcf.php method=GET> <input type=hidden name=mon value=7> <input type=hidden name=year value=2023> <TR><TD><input type=radio name=dbtable value=('Charity',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Clothing',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Food',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Housing',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Insurance',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Medical',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Personal',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Recreation',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Taxes',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Transportation',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Utilities',)></TD></TR> </form> </table> </body> </html> </nowiki></pre><br> When run through Firefox I get the page seen in the attached image Page Source from Tools->Browser Tools->Page Source looks like this <pre><nowiki><!DOCTYPE html> <html> <body> <table class=box > <TR><TH Colspan='1'>Expenses</TH></TR> <form action=viewcf.php method=GET> <input type=hidden name=mon value=7> <input type=hidden name=year value=2023> <TR><TD><input type=radio name=dbtable value=('Charity',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Clothing',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Food',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Housing',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Insurance',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Medical',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Personal',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Recreation',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Taxes',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Transportation',)></TD></TR> <TR><TD><input type=radio name=dbtable value=('Utilities',)></TD></TR> </form> </table> </body> </html></nowiki></pre><br>
已附加屏幕截图

由cor-el于修改

所有回复 (1)

more options

Firefox doesn't automatically display the value of a radio button next to the control. You can add that to your script.

https://developer.mozilla.org/docs/Web/HTML/Element/input/radio