我完全难过了。我有一个表格,已经定制了一些JS的交互性。这真的很简单。它在当地很有效。但是,在服务器上,当用户使用下拉选择时,表单将不会提交。
我看不到任何导致这种情况的事情,这让我很生气。
现场表格在这里:http://trainer.cbirt.org/events/test-event/sign-up/
现在没有压缩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);
});
});
答案 0 :(得分:0)
我可以看到有根据收音机盒隐藏/显示的字段。
我会检查以确保在表单提交时不需要这些。如果是,您可能会卡在同一页面上但没有给出任何输出,因为不显示字段错误。
您可以通过禁用无线电字段上的javascript并显示每个字段的字段错误来对此进行调试。
希望这可以提供帮助。