I have an html table calendar with the dates set to buttons. When a user clicks on the button, the button will redirect them to the appointments page. However, I need it to pass the value of the button, set to its respective date, to the appointments page as well so the user can book a meeting on that date.
<button type="button" value = "1" onclick="window.location.href='{{ url_for( 'appointments') }}';">1</button>
I would like to pass the value "1" to /appointments page when I click the button but I do not know how to do so. Is it possible to do this? Im doing this on flask python.
Appointments.html
{% extends 'base.html' %}
{% block body %}
<div class="container">
<form method="POST" action="/appointments">
<h2>Appointments</h2>
<p>
{{ form.start.label }}<br>
{{ form.start }}
</p>
<p>
{{ form.end.label }}<br>
{{ form.end }}
</p>
<p>
{{ form.description.label }}<br>
{{ form.description }}
</p>
<p>
{{ form.guestName.label }}<br>
{{ form.guestName }}
</p>
<input type="submit">
<!-- <button class = "btn btn btn-primary btn block" type="submit">Set up</button> -->
</form>
</div> <!-- /container -->
{% endblock %}
Appointment route:
@app.route('/appointments', methods=['GET', 'POST'])
def appointments():
form = AddAppointment()
if form.is_submitted():
startingTime = datetime.datetime.strptime(
form.start.data, '%H:%M').time()
endingTime = datetime.datetime.strptime(form.end.data, '%H:%M').time()
print(startingTime, endingTime)
appt = Appointments(starttime=form.start.data, endtime=form.end.data,
description=form.description.data, guestName=form.guestName.data)
print(appt)
db.session.add(appt)
db.session.commit()
return redirect('/dashboard')
return render_template('appoitments.html', form=form)