edit.ctp
2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<div class="formules form">
<?= $this->Form->create($formule) ?>
<fieldset>
<h2>
<i class="icon-plus"></i> Ajouter une formule
</h2>
<?php
echo $this->Form->control('nommesure', [
'label' => 'Nom mesure',
'required' => 'required'
]);
echo $this->Form->control('symbole', [
'label' => 'Symbole'
]);
echo $this->Form->control('unite', [
'label' => 'Unité',
'required' => 'required'
]);
echo $this->Form->control('nbVariable', [
'label' => 'Nombre de variable(5 max.)',
'default' => 1,
'empty' => 1,
'required' => 'required'
]);
?>
<div id="variable" style="display: none" required></div>
<div id="derive" style="display: none" required></div>
</fieldset>
<?= $this->Form->submit(__('Valider')) ?>
<?= $this->Form->end() ?>
</div>
<!--
<div class="actions">
<php
echo $this->element('menu');
echo $this->element('menu_form', [
'pluralHumanName' => 'Formules'
]);
?>
</div>
-->
<script type="text/javascript">
$(document).ready(function () {
variable();
$("#nbvariable").bind("focusout", function (event) {
variable();
});
});
function variable(){
var nbVariable = $("#nbvariable").val();
if(nbVariable >=1 && nbVariable<=5){
$("#variable").show();
$("#derive").show();
document.getElementById("derive").innerHTML="";
document.getElementById("variable").innerHTML ="<table><tr><td> Variables </td><td>Symbole grandeur physique</td><td>Symbole unite mesure</td><td>nom Grandeur physique</td><td>Domaine de definition</td></tr></table>";
for(var i=1;i<=nbVariable;i++){
document.getElementById("variable").innerHTML +="<table><tr><td><label>X"+i+"</label></td><td><input type=\"control\" name=\"variables["+i+"][symbolegrandeurphysique]\" required></td><td><input type=\"control\" name=\"variables["+i+"][symboleunitemesure]\" required></td><td><input type=\"control\" name=\"variables["+i+"][nomgrandeurphysique]\" required></td><td><input type=\"control\" name=\"variables["+i+"][domainedef]\" placeholder=\"ex:[X;X[\" required></td></tr></table>";
document.getElementById("derive").innerHTML += "<div class=\"input text required\"><label>Ecrire la dérivé partielle de F par rapport a la variable X"+i+"</label><input type=\"control\" name=\"variables["+i+"][derivepartielle]\" required></div>";
}
document.getElementById("derive").innerHTML += "<div class=\"input text required\"><label>Formule</label><input type=\"text\" name=\"formule\" id=\"formule\" required></div>";
}else{
alert("erreur");
}
}
</script>