<form action="{{ url_for('searchResult') }}" method="POST">
<ul style="margin-bottom: 10px;" class="list-group list-group-flush">
<li class="list-group-item"><input type="hidden" value="location"/> {{row[0]}}</li>
<li class="list-group-item">Capacity :{{row[1]}}</li>
<li class="list-group-item">Prices per night(in GBP):</li>
<li class="list-group-item">Off-Peak - {{row[2]}}</li>
<li class="list-group-item">Peak (Apr-Sept) - {{row[3]}}</li>
<li class="list-group-item"><input type="submit" value="More Info"class="btn btn-outline-info"/><input type="submit" class="btn btn-outline-success" value="Book"/></li>
</ul>
</form>
@app.route('/Locations', methods=['GET', 'POST'])
def searchResult():
if request.method == 'POST':
locationInput = request.form['location']
searchedLocation = locationInput.capitalize()
try:
conn = connection.connection()
if conn != None: #Checking if connection is None
print('MySQL Connection is established')
cursor = conn.cursor() #Creating cursor object
cursor.execute('USE {};'.format(DB_NAME)) #use database
sqlStatement = "SELECT * FROM locations;"
cursor.execute(sqlStatement)
rows = cursor.fetchall()
cursor.close()
match = False
for row in rows:
if row[0] == searchedLocation:
match = True
return render_template('locations/' searchedLocation '.html')
if match == False:
return render_template('searchError.html', searchedLocation = searchedLocation)
except:
conn.rollback()
當我點擊其中一個提交按鈕時,我想將 row[0] 的值取出到燒瓶應用程式中。這些row 值來自燒瓶應用程式的 3d 陣列,這個 html 塊在列上回圈。我想接收我單擊提交按鈕的特定塊的位置值,以便我可以移動到專門關于該位置的新頁面,并且我不希望用戶看到輸入框。我很困惑,任何幫助將不勝感激,謝謝。
uj5u.com熱心網友回復:
這有幾個問題。首先,“隱藏”項是不??可見的,因此它不應該有一個串列項(除非您希望用戶看到它)。其次,如果您希望隱藏的專案被稱為“位置”,那么它的NAME 需要是位置。該值是您要發回的值。所以:
<input type="hidden" name"location" value="{{row[0]}}">
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/429352.html
標籤:javascript Python html 形式 烧瓶
