输入域html,我可以让HTML输入表单域成为可选的吗?
嗨,我有一個HTML文件的表單。輸入數據使用Python處理,Flask使用請求.窗體. 但是,我希望某些輸入字段是可選的。當前我收到以下錯誤:400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
我認為這是由于一些領域是空的。在
我的表單是這樣設計的,有些字段只在選中單選按鈕時顯示。當表單被提交并且單選按鈕沒有被選中時,問題就出現了,因為表單只是將它們視為空。在
這是我的表格代碼:
^{pr2}$
下面的Python代碼是錯誤所在,因為如果未選中單選按鈕,它們將作為空提交。在bookingid = request.form['bookingid']
customerid = request.form['customerid']
flightid = request.form['flightid']
numseats = request.form['numofseats']
if request.form['choice']:
firstname = request.form['firstname']
surname = request.form['surname']
address = request.form['address']
email = request.form['email']
#do some SQL insert statements with ALL the form data
else:
#do some sql insert statements with the none hidden statements
誰有什么想法。在
謝謝。在
更新:更清楚地顯示我的代碼。在
總結
以上是生活随笔為你收集整理的输入域html,我可以让HTML输入表单域成为可选的吗?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Golang 入门笔记(二)中
- 下一篇: 地址总线是单向还是双向_如何区分晶闸管的