我完全被难住了。我有一个用一些 JS 定制的用于交互的表单。这真的很简单。它在本地工作得很好。但是,在服务器上,当用户使用下拉选择时,表单不会提交。
我看不到任何导致这种情况的原因,这让我发疯。
现场表格在这里:http ://trainer.cbirt.org/events/test-event/sign-up/
JS 现在没有压缩,所以我可以解决这个问题。
到目前为止,我已经尝试过:
- 吹走并重建服务器上的 VE
- 将相关的js本地放置到文件中
- 修改 js 的工作方式 七种方式到星期天
我能想到的唯一要做的事情就是在本地托管所有 JS,但这没有任何意义,因为提交不是基于 JS 的。
欢迎任何和所有建议。
表格代码:
{% extends "events/base.html" %}
{% block page_class %}full-screen{% endblock page_class %}
{% block content%}
<h1>Sign Up for {{ event.title }}</h1>
<ul class="instructions">
<li>Fill in your name and email address, and tell us if you are a Team member</li>
<li>Fill in the form that appears</li>
<li>Click Submit</li>
</ul>
{% if form.errors %}
<ul class="errors">
{% for error in form.errors %}
{% if error == "first_name" %}
<li>Please enter your <strong>first name</strong>.</li>
{% endif %}
{% if error == "last_name" %}
<li>Please enter your <strong>last name</strong>.</li>
{% endif %}
{% if error == "email" %}
<li>Please enter your <strong>email</strong>.</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
<form method="post" action="" id="signup">
{% csrf_token %}
<div class="form_block">
<label for="id_first_name">First name:</label>
<input id="id_first_name" type="text" name="first_name" maxlength="50" />
</div>
<div class="form_block">
<label for="id_last_name">Last name:</label>
<input id="id_last_name" type="text" name="last_name" maxlength="50" />
</div>
<div class="form_block">
<label for="id_email">Email:</label>
<input id="id_email" type="text" name="email" maxlength="75" />
</div>
<div class="form_block team_mem">
<label for="id_tbi_team_member">Are you a TBI Team Member?</label>
<div class="yes-no">
<span class="yes">Yes</span>
<span class="no">No</span>
</div>
<input type="checkbox" name="tbi_team_member" id="id_tbi_team_member" />
</div>
<section class="team-member">
<div class="form_block">
<label for="id_hotel_checkin_date">Hotel checkin date:</label>
<input type="text" name="hotel_checkin_date" id="id_hotel_checkin_date" />
</div>
<div class="form_block">
<label for="id_hotel_checkout_date">Hotel checkout date:</label>
<input type="text" name="hotel_checkout_date" id="id_hotel_checkout_date" />
</div>
<div class="form_block">
<label for="id_yes_share">Are you willing to share a room?</label>
<div class="yes-no">
<span class="yes">Yes</span>
<span class="no">No</span>
</div>
<input type="checkbox" name="yes_share" id="id_yes_share" />
</div>
<div class="form_block">
<label for="id_share_suite">Are you willing to share a suite?</label>
<div class="yes-no">
<span class="yes">Yes</span>
<span class="no">No</span>
</div>
<input type="checkbox" name="share_suite" id="id_share_suite" />
</div>
<div class="form_block">
<label for="id_team_dinner">Will you join us for the team dinner?</label>
<div class="yes-no">
<span class="yes">Yes</span>
<span class="no">No</span>
</div>
<input type="checkbox" name="team_dinner" id="id_team_dinner" />
</div>
</section>
<section class="not-team-member">
<div class="form_block">
<h3>Price of training per day - $40</h3>
</div>
<div class="form_block">
<label for="id_payment_method">Payment method:</label>
<select name="payment_method" id="id_payment_method">
<option value="" selected="selected">---------</option>
<option value="2">Cash</option>
<option value="3">Check</option>
<option value="4">PO</option>
</select>
</div>
<div class="form_block">
<h4>Cash and checks will be collected at the door.</h4>
</div>
</section>
<section class="general">
<div class="form_block">
<label for="id_dietary_restrictions">Do you have dietary restrictions?</label>
<input id="id_dietary_restrictions" type="text" name="dietary_restrictions" maxlength="200" />
</div>
<div class="form_block">
{% if event.pdu %}
<p>{{ event.pdu.content }}</p>
{% endif %}
{% if event.ceu %}
<p>{{ event.ceu.content }}</p>
{% endif %}
</div>
<div class="form_block">
<label for="id_your_notes">Notes and special accommodations:</label>
<textarea id="id_your_notes" rows="10" cols="40" name="your_notes"></textarea>
</div>
</section>
<div class="form_block">
<input type="submit" value="Submit" class="button" id="event-signup" />
</div>
</form>
{% endblock content %}
{% block addthis %}{% endblock addthis %}
和 JS
$('#id_payment_method').change(function(event) {
//console.log($(this));
$('option').each(function(event) {
$('option:not(:selected)').attr('selected', false);
$('option:selected').attr('selected', true);
});
});