HTML, how to auto select the date time picker from sql database
I've a HTML form for editing existing data.
Let's say today is 10/06/2022 18:05 and i want to edit my course date time in my web app. My course date on the data base is 21/08/2023 10:00. I want to change it to 22/08/2023 10:00. When I open my from on the web app all the inputs came with the existing data already selected. But date time picker comes as 10/06/2022 18:05. I've set the value as the date attribute of course object but it's not working. This works for the rest of the inputs but not for the datetime input.
I basically need the html date time picker comes with autoselected with the existing saved data <course.date> .
I'm writing this web app on python flask and using a postgresql for database. The other inputs comes with selected values but not datetime input.
Anyone has any ideas how to approach this one?
<form action="/courses/" method="post">
<label for="course">Course Title</label>
<input type="text" name="title" value="">
<label for="date">Date</label>
<input type="datetime-local" name="date" value="">
<label for="capacity">Capacity</label>
<input type="number" name="capacity" value="">
<label for="active">Active</label>
<select name="active">
<option value="True">Active</option>
<option value="False" selected >Deactive</option>
</select>
<input type='submit' value="Update Course">
</form>
Comments
Post a Comment