Using indexes of a list passed from flask in html
Question:
I’m trying to pass a list from flask via this code:
package1 = ['1', 'Jackson', 'newyork','No8', '+10880275896']
render_template("index.html", package1=package1)
on the other side I took the parameter into an html input to use it like this:
< input type="text" id="name" value="{{ package1}}" >
Please guide me anyone: "how I can access to the indexes in the HTML code"
meant for example using index 0 of the list:
package1[0]
Answers:
You can refer to the first element in the list with:
<input type="text" id="name" value="{{ package1[0] }}" >
This will render ‘1’ as the value of the input tag.
I’m trying to pass a list from flask via this code:
package1 = ['1', 'Jackson', 'newyork','No8', '+10880275896']
render_template("index.html", package1=package1)
on the other side I took the parameter into an html input to use it like this:
< input type="text" id="name" value="{{ package1}}" >
Please guide me anyone: "how I can access to the indexes in the HTML code"
meant for example using index 0 of the list:
package1[0]
You can refer to the first element in the list with:
<input type="text" id="name" value="{{ package1[0] }}" >
This will render ‘1’ as the value of the input tag.