我需要一些帮助,以便根据用户从该表单中先前字段的输入中自动填充表单上的2个字段,所有这些都基于公式。我的整个Web应用程序都可以工作,只是此功能使我感到困惑,而且我不知道如何解决它。如果这是一种非常简单/显而易见的方法,请原谅我。
routes.py: only showing that specific forms route
forms.py: showing only the Quote form
requestAQuote.html
{% extends "template.html" %}
{% block content %}
<div class="content-section">
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Request a Quote today!</legend>
<div class="form-group">
{{ form.gallons_requested.label(class="form-control-label") }}
{% if form.gallons_requested.errors %}
{{ form.gallons_requested(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.gallons_requested.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.gallons_requested(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.delivery_date.label(class="form-control-label") }}
{% if form.delivery_date.errors %}
{{ form.delivery_date(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.delivery_date.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.delivery_date(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.request_date.label(class="form-control-label") }}
{% if form.request_date.errors %}
{{ form.request_date(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.request_date.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.request_date(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.delivery_location.label(class="form-control-label") }}
{% if form.delivery_location.errors %}
{{ form.delivery_location(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.delivery_location.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.delivery_location(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.delivery_contact_name.label(class="form-control-label") }}
{% if form.delivery_contact_name.errors %}
{{ form.delivery_contact_name(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.delivery_contact_name.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.delivery_contact_name(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.delivery_contact_phone.label(class="form-control-label") }}
{% if form.delivery_contact_phone.errors %}
{{ form.delivery_contact_phone(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.delivery_contact_phone.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.delivery_contact_phone(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.delivery_contact_email.label(class="form-control-label") }}
{% if form.delivery_contact_email.errors %}
{{ form.delivery_contact_email(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.delivery_contact_email.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.delivery_contact_email(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.suggested_price.label(class="form-control-label") }}
{% if form.suggested_price.errors %}
{{ form.suggested_price(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.suggested_price.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.suggested_price(class="form-control form-control-lg") }}
{% endif %}
</div>
<div class="form-group">
{{ form.total_amount_due.label(class="form-control-label") }}
{% if form.total_amount_due.errors %}
{{ form.total_amount_due(class="form-control form-control-lg is-invalid") }}
<div class="invalid-feedback">
{% for error in form.total_amount_due.errors %}
<span>{{ error }}</span>
{% endfor %}
</div>
{% else %}
{{ form.total_amount_due(class="form-control form-control-lg") }}
{% endif %}
</div>
</fieldset>
<div class="form-group">
{{ form.get_price(class="btn btn-outline-info") }}
</div>
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
</div>
</form>
</div>
{% endblock content %}
答案 0 :(得分:0)
您可以添加一些JavaScript代码以根据您的其他字段自动填充它。 请参考这个 Auto populate field base on what was entered in another field simultaneously