Skip to content

Instantly share code, notes, and snippets.

@ouerghi
Created October 22, 2018 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouerghi/8549a6544a2af0bc37058e8fb81529df to your computer and use it in GitHub Desktop.
Save ouerghi/8549a6544a2af0bc37058e8fb81529df to your computer and use it in GitHub Desktop.
{% block javascript %}
{{ parent() }}
<script >
$(document).ready(function () {
$("select.cheque").on("change", function () {
if ($(this).val() === '0') {
$('.other').hide();
$('.err_ch').show();
} else {
$('.other').show();
$('.err_ch').hide();
}
});
$("select.oui").on("select2:select", function () {
if ($(this).val() === 'Actif secteur publique' || $(this).val() === 'Actisfs secteur privé') {
$('.yearr').hide();
$('.entr_error').show();
} else {
$('.yearr').show();
$('.entr_error').hide();
}
});
});
function countit(val) {
$('#go').html('');
for (var i = 1; i <= val; i++) {
$('#go').append('<div class="form-group mb-30 seul year' + i + '"><div class="input-group"><span class="input-group-addon">19</span><input type="text" placeholder="Année de naissance ' + i + '" id="year' + i + '" class="form-control k" onkeyup="ages(this.value,' + i + ');"><span class="input-group-addon year' + i + '"></span></div></div>');
}
}
function ages(val, num) {
var o = '19' + val;
var r = (new Date()).getFullYear() - parseInt(o);
if ((r >= 55 || r < 81) || num > 0) {
$('.year' + num).html(r + ' ans');
} else {
$('.year' + num).html('je vous remercie d’avoir pris le temps de m’écouter Mr/Mm, ce rendez-vous ne concerne que les plus de 55 ans, bonne journée');
}
if ($("input[name='indiv_val']").val() === 1) {
var hh = 0;
$(".k").each(function (index) {
hh = +hh + +(new Date()).getFullYear() - parseInt('19' + $(this).val());
});
var f = hh * 0.9;
$('#cots').html(Math.round(f));
} else {
if ((r >= 55 || r < 81) || num > 0) {
$('.year' + num).html(r + ' ans');
$('.actin').show();
} else {
$('.year' + num).html('je vous remercie d’avoir pris le temps de m’écouter Mr/Mm, ce rendez-vous ne concerne que les plus de 55 ans, bonne journée');
$('.actin').hide();
}
}
}
</script>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment