<div class="col-12">
<h6>Frequency</h6>
+ <input type="hidden" name="frequency" value="{{ frequency }}">
+
<div class="custom-control custom-radio custom-control-inline">
- <input class="custom-control-input" type="radio" name="frequency" id="frequency-one-time"
+ <input class="custom-control-input" type="radio" name="frequency-selector" id="frequency-one-time"
value="one-time" {% if frequency == "one-time" %}checked{% end %}>
<label class="custom-control-label" for="frequency-one-time">{{ _("One Time") }}</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
- <input class="custom-control-input" type="radio" name="frequency" id="frequency-monthly"
+ <input class="custom-control-input" type="radio" name="frequency-selector" id="frequency-monthly"
value="monthly" {% if frequency == "monthly" %}checked{% end %}>
<label class="custom-control-label" for="frequency-monthly">{{ _("Monthly") }}</label>
</div>
{% block javascript %}
<script type="text/javascript">
$(document).ready(function() {
- var amount = $("input[name='amount']");
- var currency = $("input[name='currency']");
- var submit = $("#donate");
- var modal = $("#modal-monthly-suggestions");
+ var amount = $("input[name='amount']");
+ var currency = $("input[name='currency']");
+ var frequency = $("input[name='frequency']");
+ var submit = $("#donate");
+ var modal = $("#modal-monthly-suggestions");
// Adjust form to default currency
if (currency.val() == "EUR") {
}
});
- // Copy amount when clicking on a radio button
+ // Copy amount when clicking on a radio buttons
$("input[name='amount-selector']").on("change", function() {
var value = $(this).val();
if (value) {
}
});
+ // Copy frequency when clicking on a radio buttons
+ $("input[name='frequency-selector']").on("change", function() {
+ var value = $(this).val();
+ if (value) {
+ frequency.val(value);
+ }
+ });
+
amount.on("change keyup mouseup", function() {
var value = $(this).val();
});
submit.click(function (event) {
- var frequency = $("input[name='frequency']").val();
-
- if (frequency == "one-time" && amount.val() > 10) {
+ if (frequency.val() == "one-time" && amount.val() > 10) {
event.preventDefault();
modal.modal("show");
$(".monthly-amount-suggestion").click(function (event) {
// Set frequency to monthly
- $("input[name='frequency']").prop("checked", false);
- $("input[name='frequency'][value='monthly']").prop("checked", true);
+ $("input[name='frequency-selector']").prop("checked", false);
+ $("input[name='frequency-selector'][value='monthly']").prop("checked", true);
+ frequency.val("monthly");
// Set amount
var value = $(this).data("amount");