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 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

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