Pass a Python + Flask variable in an HTML attribute
Question:
(Novice btw) I’m using Python + Flask
I have Python variable I want to place in as a substitute for a value=" "
My attempt: value="{{ variable }}"
didn’t work
<form>
<textarea value="{{ result }}"></textarea>
</form>
render_template("home.html", result=result)
Any guidance appreciated.
Answers:
Try <textarea>{{ result }}</textarea>
instead of <textarea value="{{ result }}"></textarea>
https://www.w3schools.com/tags/tag_textarea.asp
textarea has only four attributes "id=", "name=", "rows=", "cols="
So, If you want to put python variable in html using jinja. Use,
<textarea>{{ result }}</textarea>
or
<textarea "id=", "name=", "rows=", "cols=">{{ result }}</textarea>
(Novice btw) I’m using Python + Flask
I have Python variable I want to place in as a substitute for a value=" "
My attempt: value="{{ variable }}"
didn’t work
<form>
<textarea value="{{ result }}"></textarea>
</form>
render_template("home.html", result=result)
Any guidance appreciated.
Try <textarea>{{ result }}</textarea>
instead of <textarea value="{{ result }}"></textarea>
https://www.w3schools.com/tags/tag_textarea.asp
textarea has only four attributes "id=", "name=", "rows=", "cols="
So, If you want to put python variable in html using jinja. Use,
<textarea>{{ result }}</textarea>
or
<textarea "id=", "name=", "rows=", "cols=">{{ result }}</textarea>