<td>{{ remun.type }}</td>
<td>
{{ remun.devise }}
- <input name="montant_mois-{{ remun.id }}"
+ <input type="hidden" id="taux_devise-{{ remun.id }}"
+ name="taux_devise-{{ remun.id }}"
+ value="{{ remun.taux_devise }}" />
+ <input type="text" id="montant_mois-{{ remun.id }}"
+ name="montant_mois-{{ remun.id }}"
value="{{ remun.montant_mois }}" /></td>
- <td><input name="cg-montant-{{ remun.id }}"
+ <td><input type="text" id="montant-{{ remun.id }}"
+ name="cg-montant-{{ remun.id }}"
value="{{ remun.montant|default_if_none:'' }}" /></td>
- <td>{{ remun.montant_euro_mois }}</td>
- <td>{{ remun.montant_euro }}</td>
- <td><input name="cg-precision-{{ remun.id }}"
+ <td id="montant_euro_mois-{{ remun.id }}">
+ {{ remun.montant_euro_mois }}</td>
+ <td id="montant_euro-{{ remun.id }}">{{ remun.montant_euro }}</td>
+ <td><input type="text" name="cg-precision-{{ remun.id }}"
value="{{ remun.precision|default_if_none:'' }}" /></td>
</tr>
{% empty %}
</fieldset>
+ <script type="text/javascript">
+ function round2(n) {
+ return Math.round(n * 100) / 100;
+ }
+
+ $('#global-cost input[id^="montant"]').live('keyup', function() {
+ var value = $(this).val(),
+ idParts = $(this).attr('id').split('-'),
+ name = idParts[0],
+ id = idParts[1];
+ if (name == 'montant') {
+ $('#montant_mois-' + id).val(round2(value / 12));
+ } else {
+ value = value * 12;
+ $('#montant-' + id).val(round2(value));
+ }
+ var taux = $('#taux_devise-' + id).val();
+ $('#montant_euro_mois-' + id).text(round2(value / taux / 12));
+ $('#montant_euro-' + id).text(round2(value / taux));
+ });
+ </script>
+
<h2 class="section">SECTION 4 - JUSTIFICATION DE LA DEMANDE (OBLIGATOIRE)</h2>
<input type="submit" name="save" value="Sauvegarder" />