I'm new to Flask and looking for a way to parse one or n values of a jinja variable.
The app route hands an object over to the html template.
`selection2 = db.execute("SELECT user.id, bikes.id, bikes.name, bikeshopname, price, city, img, enddate FROM user LEFT JOIN bikes ON user.id = bikes.userid LEFT JOIN renthistory ON bikes.id = renthistory.bikeid WHERE user.city = :city AND price NOT NULL", city=select_city)
return render_template("/bikes.html", selection2=selection2)`
In the template I implemented it like this:
{% for row in selection2 %}
<p id="enddate" value="{{row["enddate"]}}"></p>
{% endfor %}
In the js function I get the value (a certain date) of that particular paragraph. So it works for the first item.
function getBikeRentEndDate() {
let enddate = (document.getElementById("enddate").innerHTML);
document.getElementById('showdate').innerHTML = enddate;
}
But what I want is to look in all the created once the template is rendered. And then show a message if a condition is true. Something like "if date is => today - show a message.
I know there is a way but after researching and trail and erroring for quite a while, I hope someone can point it out.
id. Ids should be unique. You should use classes instead