关于帐户注册的下拉选项,我有一个快速的问题。我有2个字段,分别是Acccount
类型和Business
类型。帐户类型是一个带2个选项的下拉列表,分别为“ Vendor
”和“ Venue
”。业务类型是具有许多选项的下拉列表。如果在“帐户类型”下拉列表中选择了“ Vendor
”,我仅希望下拉列表选项可访问。我可以使用if else语句在模板中处理吗?我有一个小片段可供参考。
<div class="form-group">
<label for="account_type">Account Type<span>*</span></label>
<div class="select-panel required">
<select required class="selectpicker" name="account" id="multi-category"
title="Select a category">
<option>Vendor</option>
<option>Venue</option>
</select>
<span id="span_account_type" class="error-msg"></span>
</div>
<!--<input type="text" name="business_type" class="form-control required" id="business_type" placeholder="Business Type" value="{{business}}" maxlength="20">-->
{% if account_error %}
<span class="error-msg">
{{account_error}}
</span>
{% endif %}
</div>
<div class="form-group">
<label for="business_type">Business Type<span>*</span></label>
<div class="select-panel required">
<select class="selectpicker" name="business" multiple="multiple" id="multi-category"
title="Select a category">
{% for business in business_types %}
<option value="{{ business.id }}">{{ business.name }}</option>
{% endfor %}
{% endif %}
</div>
我尝试添加类似的内容,但是没有运气。
{% if account == 'Venue' %}
<option>-----</option>
{% else %}
{% for business in business_types %}
<option value="{{ business.id }}">{{ business.name }}</option>
{% endfor %}
{% endif %}