Issue
How do I set the VALUE
attribut of a text input field (HTML forms).
I tried it with:
Python:
@app.route("/function_a", methods=['GET', 'POST'])
def function_a():
form = ReusableForm(request.form)
query = "test value"
if request.method == 'POST':
name=request.form['name']
return render_template('zeit.html', form=form, query_test=query)
HTML template:
{{ form.name(value="{{ query_test }}") }}
the website output is like:
<input id="name" name="name" required type="text" value="{{query_test}}">
expected website output:
<input id="name" name="name" required type="text" value="test value">
Solution
I got the solution:
in the HTML template I wrote only the variable without the brackets.
{{ form.name(value=query_test) }}
and the output is like I want it:
<input id="name" name="name" required type="text" value="test value">
Answered By - Dinera
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.